-
Notifications
You must be signed in to change notification settings - Fork 2
/
c64joy.ino
38 lines (26 loc) · 838 Bytes
/
c64joy.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <Keyboard.h>
#define JOY_UP 11
#define JOY_DOWN 10
#define JOY_LEFT 9
#define JOY_RIGHT 8
#define JOY_BUTTON 12
void setup() {
Keyboard.begin();
pinMode(JOY_BUTTON, INPUT_PULLUP);
pinMode(JOY_UP, INPUT_PULLUP);
pinMode(JOY_DOWN, INPUT_PULLUP);
pinMode(JOY_LEFT, INPUT_PULLUP);
pinMode(JOY_RIGHT, INPUT_PULLUP);
}
void loop() {
if (!digitalRead(JOY_BUTTON)) { Keyboard.press('q'); }
else { Keyboard.release('q'); }
if (!digitalRead(JOY_UP)) { Keyboard.press('w'); }
else { Keyboard.release('w'); }
if (!digitalRead(JOY_DOWN)) { Keyboard.press('s'); }
else { Keyboard.release('s'); }
if (!digitalRead(JOY_LEFT)) { Keyboard.press('a'); }
else { Keyboard.release('a'); }
if (!digitalRead(JOY_RIGHT)) { Keyboard.press('d'); }
else { Keyboard.release('d'); }
}