-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicNumberKeyBoard.ino
173 lines (130 loc) · 2.77 KB
/
BasicNumberKeyBoard.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
0 =48
1 =49
2 =50
3 =51
4 =52
5 =53
6 =54
7 =55
8 =56
9 =57
*/
#include <Keyboard.h>
const int button1 = 2;
const int button2 = 3;
const int button3 = 4;
const int button4 = 5;
const int button5 = 6;
const int button6 = 7;
const int button7 = 8;
const int button8 = 9;
const int button9 = 10;
const int button10 = 11;
void setup() {
// put your setup code here, to run once:
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);
pinMode(button5, INPUT_PULLUP);
pinMode(button6, INPUT_PULLUP);
pinMode(button7, INPUT_PULLUP);
pinMode(button8, INPUT_PULLUP);
pinMode(button9, INPUT_PULLUP);
pinMode(button10, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
// put your main code here, to run repeatedly:
int buttonState1 = digitalRead(button1);
int buttonState2 = digitalRead(button2);
int buttonState3 = digitalRead(button3);
int buttonState4 = digitalRead(button4);
int buttonState5 = digitalRead(button5);
int buttonState6 = digitalRead(button6);
int buttonState7 = digitalRead(button7);
int buttonState8 = digitalRead(button8);
int buttonState9 = digitalRead(button9);
int buttonState10 = digitalRead(button10);
if (buttonState1 == LOW) {
Keyboard.press(48);
delay(50);
}
else if(buttonState1 == HIGH) {
Keyboard.release(48);
delay(50);
}
if (buttonState2 == LOW) {
Keyboard.press(49);
delay(50);
}
else if(buttonState2 == HIGH) {
Keyboard.release(49);
delay(50);
}
if (buttonState3 == LOW) {
Keyboard.press(50);
delay(50);
}
else if(buttonState3 == HIGH) {
Keyboard.release(50);
delay(50);
}
if (buttonState4 == LOW) {
Keyboard.press(51);
delay(50);
}
else if(buttonState4 == HIGH) {
Keyboard.release(51);
delay(50);
}
if (buttonState5 == LOW) {
Keyboard.press(52);
delay(50);
}
else if(buttonState5 == HIGH) {
Keyboard.release(52);
delay(50);
}
if (buttonState6 == LOW) {
Keyboard.press(53);
delay(50);
}
else if(buttonState6 == HIGH) {
Keyboard.release(53);
delay(50);
}
if (buttonState7 == LOW) {
Keyboard.press(54);
delay(50);
}
else if(buttonState7 == HIGH) {
Keyboard.release(54);
delay(50);
}
if (buttonState8 == LOW) {
Keyboard.press(55);
delay(50);
}
else if(buttonState8 == HIGH) {
Keyboard.release(55);
delay(50);
}
if (buttonState9 == LOW) {
Keyboard.press(56);
delay(50);
}
else if(buttonState9 == HIGH) {
Keyboard.release(56);
delay(50);
}
if (buttonState10 == LOW) {
Keyboard.press(57);
delay(50);
}
else if(buttonState10 == HIGH) {
Keyboard.release(57);
delay(50);
}
}