This project provides an USB keyboard emulator to be activated by feet either individually or simultaneously.
It is based on a DigisPark board with updated DigiKeyboard.h library.
Files
DigiKeyboard_6keys.h
Digikeyboard.h modified to allow up to 6 simultaneous keypresses and renamed
As mentioned in previous log I have built a spinoff version of the project. Here are the details:
Only 3 components were used to built the unit (besides the footswitch itself as well as the USB cable).
A Digispark Clone
A P10 jack
A small box
The plastic flanges were trimmed and a hole was made for the P10 jack
Then another hole was made on the opposite side of the box for the USB connector. The board was attached to the bottom cover of the box using two threaded screws.
The plastic spacers were trimmed to match the height of the board with the window for the USB connector.
The Jack was then wired to the board. Since the switch is Normally Closed a bridge wire was used to keep the wires short circuited when the plug is not inserted.
The firmware was then uploaded and the pedal was tested using a web application from Microsoft from a page about keyboard ghosting (very interesting by the way).
While developing a spinoff version using an electric keyboard footswitch I found that such footswitch is normaly closed, and opens when you step over it.
No problem. it is simply a matter of changing a compare value.
if ((digitalRead(_Pin_Left_footswitch) == 0)) footkeys |= (1 << _Pin_Left_footswitch);
if ((digitalRead(_Pin_Middle_footswitch) == 0)) footkeys |= (1 << _Pin_Middle_footswitch);
if ((digitalRead(_Pin_Right_footswitch) == 1)) footkeys |= (1 << _Pin_Right_footswitch); // use a NC contact
The first tests have been performed using the #SILSpark board which has no pulldowns or pullups in pin 1 (PB1), but when using digispark it is necessary to change the pin connections:
Spent some time trying to figure out how to allow simultaneous keypresses using DigiKeyboard Library.
Both the problem and the solution were right in front of me but took some time until I figure out that the report size of only one keystroke was hardcoded in Digikeyboard.h file.
Under Linux /home/username/.arduino15/packages/digistump/hardware/avr/1.6.7/libraries/DigisparkKeyboard/
3
Include the modified library in your project
Whenever is necessary to use the modified version with 6 simultaneous keys, include the following library
#include "DigiKeyboard_6keys.h"
Then you can send simultaneous keys by adding keystrokes to output buffer
// clear buffer by defaultmemset( DigiKeyboard.reportBuffer , 0, sizeof( DigiKeyboard.reportBuffer));
// Now add up to 6 keys to report
DigiKeyboard.reportBuffer[i++] = _Key_A;
DigiKeyboard.reportBuffer[i++] = _Key_B;
DigiKeyboard.reportBuffer[i++] = _Key_C;
DigiKeyboard.reportBuffer[i++] = _Key_D;
DigiKeyboard.reportBuffer[i++] = _Key_E;
DigiKeyboard.reportBuffer[i++] = _Key_F;
// Now set to send the keystrokes in the next USB interrupt
usbSetInterrupt( DigiKeyboard.reportBuffer, sizeof(DigiKeyboard.reportBuffer));
while (!usbInterruptIsReady()) {
usbPoll();
_delay_ms(5);
}
To release all the keys, simply send a clear buffer