Skip to content

Instantly share code, notes, and snippets.

@PierreZ
Created January 27, 2018 20:43
Show Gist options
  • Save PierreZ/6557e8b36f7ab93561c187259d2d775b to your computer and use it in GitHub Desktop.
Save PierreZ/6557e8b36f7ab93561c187259d2d775b 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