Created
November 3, 2012 02:23
-
-
Save houmei/4005551 to your computer and use it in GitHub Desktop.
Pinball Controller by Arduino Leonardo
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
// 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