Skip to content

Instantly share code, notes, and snippets.

@PierreZ
Created September 8, 2018 11:08
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 PierreZ/3a75aab591d05a8a57464f81c9c59a59 to your computer and use it in GitHub Desktop.
Save PierreZ/3a75aab591d05a8a57464f81c9c59a59 to your computer and use it in GitHub Desktop.
#include <Keyboard.h>
void setup() {
pinMode(2, INPUT_PULLUP);
// pinMode(4, INPUT_PULLUP);
pinMode(13, OUTPUT);
Keyboard.begin();
}
void loop() {
while (digitalRead(2)==HIGH){
delay(10);
}
digitalWrite(13, HIGH);
//if(digitalRead(4)==HIGH){
Keyboard.press(KEY_LEFT_ARROW); // Player 1
//} else {
//Keyboard.press(KEY_UP_ARROW); // Player 2
//}
delay(2);
Keyboard.releaseAll();
while (digitalRead(2)==LOW) {
delay(10);
}
digitalWrite(13, LOW);
//if(digitalRead(4)==HIGH){
Keyboard.press(KEY_RIGHT_ARROW); // Player 1
//} else {
//Keyboard.press(KEY_DOWN_ARROW); // Player 2
//}
delay(2);
Keyboard.releaseAll();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment