1const int leftButton = 2;
2const int rightButton = 13;
3
4int left_ledState = LOW;
5int left_buttonState;
6int left_lastButtonState = HIGH;
7int right_ledState = LOW;
8int right_buttonState;
9int right_lastButtonState = HIGH;
10
11
12
13long lastDebounceTime = 0;
14long debounceDelay = 50;
15
16void setup() {
17pinMode(12, OUTPUT);
18pinMode(11, OUTPUT);
19pinMode(10, OUTPUT);
20pinMode(9, OUTPUT);
21pinMode(8, OUTPUT);
22pinMode(7, OUTPUT);
23pinMode(6, OUTPUT);
24pinMode(5, OUTPUT);
25pinMode(4, OUTPUT);
26pinMode(3, OUTPUT);
27pinMode(rightButton, INPUT);
28pinMode(leftButton, INPUT);
29Serial.begin(9600);
30}
31
32void loop() {
33
34
35
36
37
38 int left_reading = digitalRead(leftButton);
39
40
41
42
43
44
45 if (left_reading != left_lastButtonState) {
46
47 lastDebounceTime = millis();
48 }
49
50 if ((millis() - lastDebounceTime) > debounceDelay) {
51
52
53
54
55 if (left_reading != left_buttonState) {
56 left_buttonState = left_reading;
57
58 digitalWrite(12, left_ledState);
59 digitalWrite(11, left_ledState);
60 digitalWrite(10, left_ledState);
61 digitalWrite(9, left_ledState);
62 digitalWrite(8, left_ledState);
63 delay(500);
64 digitalWrite(12, !left_ledState);
65 digitalWrite(11, !left_ledState);
66 digitalWrite(10, !left_ledState);
67 digitalWrite(9, !left_ledState);
68 digitalWrite(8, !left_ledState);
69 delay(500);
70
71 digitalWrite(12, left_ledState);
72 digitalWrite(11, left_ledState);
73 digitalWrite(10, left_ledState);
74 digitalWrite(9, left_ledState);
75 digitalWrite(8, left_ledState);
76 delay(500);
77 digitalWrite(12, !left_ledState);
78 digitalWrite(11, !left_ledState);
79 digitalWrite(10, !left_ledState);
80 digitalWrite(9, !left_ledState);
81 digitalWrite(8, !left_ledState);
82 delay(500);
83
84 digitalWrite(12, left_ledState);
85 digitalWrite(11, left_ledState);
86 digitalWrite(10, left_ledState);
87 digitalWrite(9, left_ledState);
88 digitalWrite(8, left_ledState);
89 delay(500);
90 digitalWrite(12, !left_ledState);
91 digitalWrite(11, !left_ledState);
92 digitalWrite(10, !left_ledState);
93 digitalWrite(9, !left_ledState);
94 digitalWrite(8, !left_ledState);
95 delay(500);
96
97 digitalWrite(12, left_ledState);
98 digitalWrite(11, left_ledState);
99 digitalWrite(10, left_ledState);
100 digitalWrite(9, left_ledState);
101 digitalWrite(8, left_ledState);
102 delay(500);
103 digitalWrite(12, !left_ledState);
104 digitalWrite(11, !left_ledState);
105 digitalWrite(10, !left_ledState);
106 digitalWrite(9, !left_ledState);
107 digitalWrite(8, !left_ledState);
108 delay(500);
109
110 digitalWrite(12, left_ledState);
111 digitalWrite(11, left_ledState);
112 digitalWrite(10, left_ledState);
113 digitalWrite(9, left_ledState);
114 digitalWrite(8, left_ledState);
115 delay(500);
116 digitalWrite(12, !left_ledState);
117 digitalWrite(11, !left_ledState);
118 digitalWrite(10, !left_ledState);
119 digitalWrite(9, !left_ledState);
120 digitalWrite(8, !left_ledState);
121 delay(500);
122 }
123
124
125 if (left_buttonState == LOW) {
126 digitalWrite(12, LOW);
127 digitalWrite(11, LOW);
128 digitalWrite(10, LOW);
129 digitalWrite(9, LOW);
130 digitalWrite(8, LOW);
131 }
132
133 }
134
135
136 left_lastButtonState = left_reading;
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153int right_reading = digitalRead(rightButton);
154
155
156
157
158
159
160 if (right_reading != right_lastButtonState) {
161
162 lastDebounceTime = millis();
163 }
164
165 if ((millis() - lastDebounceTime) > debounceDelay) {
166
167
168
169
170 if (right_reading != right_buttonState) {
171 right_buttonState = right_reading;
172
173 digitalWrite(7, right_ledState);
174 digitalWrite(6, right_ledState);
175 digitalWrite(5, right_ledState);
176 digitalWrite(4, right_ledState);
177 digitalWrite(3, right_ledState);
178 delay(500);
179 digitalWrite(7, !right_ledState);
180 digitalWrite(6, !right_ledState);
181 digitalWrite(5, !right_ledState);
182 digitalWrite(4, !right_ledState);
183 digitalWrite(3, !right_ledState);
184 delay(500);
185
186 digitalWrite(7, right_ledState);
187 digitalWrite(6, right_ledState);
188 digitalWrite(5, right_ledState);
189 digitalWrite(4, right_ledState);
190 digitalWrite(3, right_ledState);
191 delay(500);
192 digitalWrite(7, !right_ledState);
193 digitalWrite(6, !right_ledState);
194 digitalWrite(5, !right_ledState);
195 digitalWrite(4, !right_ledState);
196 digitalWrite(3, !right_ledState);
197 delay(500);
198
199 digitalWrite(7, right_ledState);
200 digitalWrite(6, right_ledState);
201 digitalWrite(5, right_ledState);
202 digitalWrite(4, right_ledState);
203 digitalWrite(3, right_ledState);
204 delay(500);
205 digitalWrite(7, !right_ledState);
206 digitalWrite(6, !right_ledState);
207 digitalWrite(5, !right_ledState);
208 digitalWrite(4, !right_ledState);
209 digitalWrite(3, !right_ledState);
210 delay(500);
211
212 digitalWrite(7, right_ledState);
213 digitalWrite(6, right_ledState);
214 digitalWrite(5, right_ledState);
215 digitalWrite(4, right_ledState);
216 digitalWrite(3, right_ledState);
217 delay(500);
218 digitalWrite(7, !right_ledState);
219 digitalWrite(6, !right_ledState);
220 digitalWrite(5, !right_ledState);
221 digitalWrite(4, !right_ledState);
222 digitalWrite(3, !right_ledState);
223 delay(500);
224
225 digitalWrite(7, right_ledState);
226 digitalWrite(6, right_ledState);
227 digitalWrite(5, right_ledState);
228 digitalWrite(4, right_ledState);
229 digitalWrite(3, right_ledState);
230 delay(500);
231 digitalWrite(7, !right_ledState);
232 digitalWrite(6, !right_ledState);
233 digitalWrite(5, !right_ledState);
234 digitalWrite(4, !right_ledState);
235 digitalWrite(3, !right_ledState);
236 delay(500);
237 }
238
239
240 if (right_buttonState == LOW) {
241 digitalWrite(7, LOW);
242 digitalWrite(6, LOW);
243 digitalWrite(5, LOW);
244 digitalWrite(4, LOW);
245 digitalWrite(3, LOW);
246 }
247 }
248
249
250
251 right_lastButtonState = right_reading;
252
253
254}
Tishin
6 days ago
Very Cool. Thanks for sharing this project. It's nice to see when people take the time to make practical projects.