Skip to content

Instantly share code, notes, and snippets.

Created May 28, 2014 15:40
Show Gist options
  • Save anonymous/62e521f4b84866c76277 to your computer and use it in GitHub Desktop.
Save anonymous/62e521f4b84866c76277 to your computer and use it in GitHub Desktop.
Arduino Leonardo: Send key when a button is pressed.
// Arduino Leonardo: Send key when a button is pressed.
void setup() {
pinMode(12, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
//if the button is pressed
if(digitalRead(12)==LOW){
Keyboard.press(KEY_LEFT_ALT);
Keyboard.press(KEY_F12);
delay(100);
Keyboard.releaseAll();
delay(200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment