Skip to content

Instantly share code, notes, and snippets.

@joshlove
Created May 29, 2017 15:43
Show Gist options
  • Save joshlove/ff95cf346567ff670458df32f2135ce4 to your computer and use it in GitHub Desktop.
Save joshlove/ff95cf346567ff670458df32f2135ce4 to your computer and use it in GitHub Desktop.
keyboard footswitch
#include <Bounce.h>
const int yPin = 0;
const int hPin = 1;
const int nPin = 2;
Bounce yB = Bounce(yPin, 10);
Bounce hB = Bounce(hPin, 10);
Bounce nB = Bounce(nPin, 10);
void setup() {
pinMode(yPin, INPUT_PULLUP);
pinMode(hPin, INPUT_PULLUP);
pinMode(nPin, INPUT_PULLUP);
}
void loop() {
if(yB.update()){
if (yB.fallingEdge()) {
Keyboard.press('y');
}
if (yB.risingEdge()){
Keyboard.release('y');
}
}
if(hB.update()){
if (hB.fallingEdge()) {
Keyboard.press('h');
}
if (hB.risingEdge()){
Keyboard.release('h');
}
}
if(nB.update()){
if (nB.fallingEdge()) {
Keyboard.press('n');;
}
if (nB.risingEdge()){
Keyboard.release('n');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment