Skip to content

Instantly share code, notes, and snippets.

@houmei
Created November 3, 2012 02:23
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 houmei/4005551 to your computer and use it in GitHub Desktop.
Save houmei/4005551 to your computer and use it in GitHub Desktop.
Pinball Controller by Arduino Leonardo
// Pinball controller
// Arduino Leonardo
// 20121102 K.takesita
//
int Tilt=A1;
int Rpaddle=A3;
int Lpaddle=A4;
int Shoot=A5;
void setup() {
// Serial.begin(9600);
pinMode(Tilt,INPUT_PULLUP);
pinMode(Lpaddle,INPUT_PULLUP);
pinMode(Rpaddle,INPUT_PULLUP);
pinMode(Shoot,INPUT_PULLUP);
}
void loop() {
int T=digitalRead(Tilt);
int L=digitalRead(Lpaddle);
int R=digitalRead(Rpaddle);
int S=digitalRead(Shoot);
if (L==0) {
Keyboard.press(KEY_LEFT_SHIFT);
} else {
Keyboard.release(KEY_LEFT_SHIFT);
}
if (R==0) {
Keyboard.press(KEY_RIGHT_SHIFT);
} else {
Keyboard.release(KEY_RIGHT_SHIFT);
}
if (T==0) {
Keyboard.press(' ');
} else {
Keyboard.release(' ');
}
if (S==0) {
Keyboard.press(KEY_RETURN);
} else {
Keyboard.release(KEY_RETURN);
}
delay(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment