Created
May 29, 2017 15:43
-
-
Save joshlove/ff95cf346567ff670458df32f2135ce4 to your computer and use it in GitHub Desktop.
keyboard footswitch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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