Created
August 6, 2013 20:38
-
-
Save mathias/6168386 to your computer and use it in GitHub Desktop.
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
/* | |
* A vim insert mode foot pedal | |
*/ | |
#include <Bounce.h> | |
int ledPin = 11; | |
int footPedalPin = 9; | |
// 10 = debounce time in ms | |
Bounce button = Bounce(footPedalPin, 10); | |
void setup() { | |
Serial.begin(9600); | |
pinMode(footPedalPin, INPUT_PULLUP); | |
pinMode(ledPin, OUTPUT); | |
Keyboard.begin(); | |
delay(1000); | |
Serial.println("All set"); | |
} | |
void loop() { | |
button.update(); | |
if (button.fallingEdge()) { | |
// enter insert | |
Keyboard.write("i"); | |
digitalWrite(ledPin, HIGH); | |
} else if (button.risingEdge()) { | |
// leave insert | |
// We have to build Ctrl-[ to leave insert since | |
// the ESC key does not seem to be detected on OSX. | |
Keyboard.press(KEY_LEFT_CTRL); | |
Keyboard.press('['); | |
Keyboard.releaseAll(); | |
digitalWrite(ledPin, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment