18
18
**/
19
19
20
20
// Aesthetics
21
- #define TAP_MS 200 // When a tap becomes a hold in milliseconds
21
+ #define TAP_MS 20 // When a tap becomes a hold in milliseconds
22
22
23
23
// MAX_KEYS must be larger than the highest IO pin on the board used for keymapping
24
24
// In this case it's digital pin 13. 20 > 13, so MAX_KEYS of 20 is fine.
@@ -35,7 +35,7 @@ static bool STATE_MAP[MAX_KEYS];
35
35
#define KEY_C 11
36
36
#define KEY_D 10
37
37
#define KEY_E 9
38
- #define KEY_F 8
38
+ #define KEY_F 6
39
39
40
40
void setup () {
41
41
// Assign each key to produce a character output.
@@ -71,39 +71,38 @@ void setup() {
71
71
pinMode (KEY_E, INPUT_PULLUP);
72
72
pinMode (KEY_F, INPUT_PULLUP);
73
73
74
-
75
-
76
- // Keyboard.begin();
74
+ Keyboard.begin ();
77
75
Serial.begin (9600 );
78
- delay (5000 );
76
+ // delay(5000);
79
77
Serial.println (" Begin!" );
80
78
}
81
79
82
- void stateCheck (int incomingKey, char * output ) {
80
+ void stateCheck (int incomingKey) {
83
81
bool incoming = digitalRead (incomingKey);
84
82
85
83
if (incoming == STATE_MAP[incomingKey]) {
86
84
return ;
87
85
}
88
86
89
- strcat (output, &KEY_MAP[incomingKey]);
90
-
87
+ if (incoming == LOW) {
88
+ Serial.print (" X " );
89
+ Serial.println (KEY_MAP[incomingKey]);
90
+ Keyboard.press (KEY_MAP[incomingKey]);
91
+ } else {
92
+ Serial.print (" O " );
93
+ Serial.println (KEY_MAP[incomingKey]);
94
+ Keyboard.release (KEY_MAP[incomingKey]);
95
+ }
96
+
91
97
STATE_MAP[incomingKey] = incoming;
92
98
}
93
99
94
100
void loop () {
95
- char output[12 ] = {' \0 ' };
96
- stateCheck (KEY_A, output);
97
- stateCheck (KEY_B, output);
98
- stateCheck (KEY_C, output);
99
- stateCheck (KEY_D, output);
100
- stateCheck (KEY_E, output);
101
- stateCheck (KEY_F, output);
102
-
103
- Serial.println (output);
101
+ stateCheck (KEY_A);
102
+ stateCheck (KEY_B);
103
+ stateCheck (KEY_C);
104
+ stateCheck (KEY_D);
105
+ stateCheck (KEY_E);
106
+ stateCheck (KEY_F);
104
107
delay (TAP_MS);
105
-
106
- // Keyboard.print("You pressed the button ");
107
- // Keyboard.print(counter);
108
- // Keyboard.println(" times.");
109
108
}
0 commit comments