Skip to content

Instantly share code, notes, and snippets.

@raster
Last active October 5, 2015 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raster/2760304 to your computer and use it in GitHub Desktop.
Save raster/2760304 to your computer and use it in GitHub Desktop.
Simple two button control with a Teensy #3
/*
* Button.pde
*
* Created in collaboration with Basti Böhm
*
*/
void setup() {
Serial.begin(9600);
pinMode(10, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
delay(4000);
}
void loop() {
if (digitalRead(10) == HIGH) {
delay(10);
}
else {
Keyboard.set_modifier(0);
Keyboard.set_key1(KEY_SPACE);
Keyboard.send_now();
releasekey();
delay(500);
}
if (digitalRead(9) == HIGH) {
delay(10);
}
else {
Keyboard.set_modifier(0);
Keyboard.set_key1(KEY_ESC);
Keyboard.send_now();
releasekey();
delay(500);
}
delay(10);
}
void releasekey() {
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment