Skip to content

Instantly share code, notes, and snippets.

@dsvictor94
Forked from anonymous/sketch_dec16a.ino
Last active February 20, 2017 20:37
Show Gist options
  • Save dsvictor94/c78895ac60187f8a00f54a52596e321e to your computer and use it in GitHub Desktop.
Save dsvictor94/c78895ac60187f8a00f54a52596e321e to your computer and use it in GitHub Desktop.
#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