-
-
Save dsvictor94/c78895ac60187f8a00f54a52596e321e 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
#include <Keyboard.h> | |
#include <SoftwareSerial.h> | |
// give it a name: Game control | |
// Pin names | |
int space = 2; //space | |
int up = 6; //up | |
int down = 12; //down | |
int left = 13; //left | |
int right = 8; //right | |
//The setup routine runs once when you press reset: | |
void setup() { | |
pinMode(space, INPUT_PULLUP); | |
pinMode(up, INPUT_PULLUP); | |
pinMode(down, INPUT_PULLUP); | |
pinMode(left, INPUT_PULLUP); | |
pinMode(right, INPUT_PULLUP); | |
Keyboard.begin(); | |
} | |
//the loop routine runs over and over again forever: | |
void loop(){ | |
while(digitalRead(space) == HIGH){ | |
Keyboard.println("Space"); | |
} | |
while(digitalRead(up) == HIGH){ | |
Keyboard.println("Up"); | |
} | |
while(digitalRead(down) == HIGH){ | |
Keyboard.println("Down"); | |
} | |
while(digitalRead(left) == HIGH){ | |
Keyboard.println("Left"); | |
} | |
while(digitalRead(right) == HIGH){ | |
Keyboard.println("Right"); | |
} | |
printf("\n"); | |
delay("50000000"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment