-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinal_showcase_version
307 lines (262 loc) · 6.56 KB
/
final_showcase_version
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
//c1 - defining led/button pins [opportunity, 2but]
#define ledPin 22
#define buttonPin 2
#define buttonPin2 3
//c2 [who is jtr, 3but]
#define ledPin2 24
#define buttonPin3 4
#define buttonPin4 5
#define buttonPin5 6
//c3 [motive, 2but]
#define ledPin3 26
#define buttonPin6 7
#define buttonPin7 8
//c4 [target & victims, 2but]
#define ledPin4 28
#define buttonPin8 9
#define buttonPin9 10
//c5 [killing stop, 3but]
#define ledPin5 30
#define buttonPin10 11
#define buttonPin11 12
#define buttonPin12 13
int C1 = 0;
int C2 = 0;
int C3 = 0;
int C4 = 0;
int C5 = 0;
//c1 - boolean of led/buttonpress
boolean ledState = LOW;
boolean btnPressed = false;
boolean btnPressed2 = false;
//c2
boolean ledState2 = LOW;
boolean btnPressed3 = false;
boolean btnPressed4 = false;
boolean btnPressed5 = false;
//c3
boolean ledState3 = LOW;
boolean btnPressed6 = false;
boolean btnPressed7 = false;
//c4
boolean ledState4 = LOW;
boolean btnPressed8 = false;
boolean btnPressed9 = false;
//c5
boolean ledState5 = LOW;
boolean btnPressed10 = false;
boolean btnPressed11 = false;
boolean btnPressed12 = false;
unsigned long previousMillis = 0; // will store last time LED was updated
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long previousMillis4 = 0;
unsigned long previousMillis5 = 0;
const long interval = 5000;
const long interval2 = 8000;
const long interval3 = 5000;
const long interval4 = 5000;
const long interval5 = 8000;
void setup() {
Serial.begin(9600);
//c1 - defining led/button input & output
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin2, INPUT);
digitalWrite(ledPin, LOW);
//c2
pinMode(ledPin2, OUTPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
digitalWrite(ledPin2, LOW);
//c3
pinMode(ledPin3, OUTPUT);
pinMode(buttonPin6, INPUT);
pinMode(buttonPin7, INPUT);
digitalWrite(ledPin3, LOW);
//c4
pinMode(ledPin4, OUTPUT);
pinMode(buttonPin8, INPUT);
pinMode(buttonPin9, INPUT);
digitalWrite(ledPin4, LOW);
//c5
pinMode(ledPin5, OUTPUT);
pinMode(buttonPin10, INPUT);
pinMode(buttonPin11, INPUT);
pinMode(buttonPin12, INPUT);
digitalWrite(ledPin5, LOW);
}
void loop() {
unsigned long currentMillis = millis();
unsigned long currentMillis2 = millis();
unsigned long currentMillis3 = millis();
unsigned long currentMillis4 = millis();
unsigned long currentMillis5 = millis();
//c1 - boolean check for button
boolean btnState = digitalRead(buttonPin);
boolean btnState2 = digitalRead(buttonPin2);
//c2
boolean btnState3 = digitalRead(buttonPin3);
boolean btnState4 = digitalRead(buttonPin4);
boolean btnState5 = digitalRead(buttonPin5);
//c3
boolean btnState6 = digitalRead(buttonPin6);
boolean btnState7 = digitalRead(buttonPin7);
//c4
boolean btnState8 = digitalRead(buttonPin8);
boolean btnState9 = digitalRead(buttonPin9);
//c5
boolean btnState10 = digitalRead(buttonPin10);
boolean btnState11 = digitalRead(buttonPin11);
boolean btnState12 = digitalRead(buttonPin12);
/* button checker (whether if the button works)
Serial.print(btnState);
Serial.print(",");
Serial.print(btnState2);
Serial.print(",");
Serial.print(btnState3);
Serial.print(",");
Serial.print(btnState4);
Serial.print(",");
Serial.print(btnState5);
Serial.print(",");
Serial.print(btnState6);
Serial.print(",");
Serial.print(btnState7);
Serial.print(",");
Serial.print(btnState8);
Serial.print(",");
Serial.print(btnState9);
Serial.print(",");
Serial.print(btnState10);
Serial.print(",");
Serial.print(btnState11);
Serial.print(",");
Serial.println(btnState12);
delay(100);
*/
// C1 (2 buttons)
if ( btnState == HIGH && btnPressed == LOW ) {
C1 = C1 + 1;
btnPressed = true;
}
if ( btnState2 == HIGH && btnPressed2 == LOW ) {
C1 = C1 + 1;
btnPressed2 = true;
}
if(C1 == 2){
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
// reset to base timer
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
C1 = 0;
btnPressed = false;
btnPressed2 = false;
}
}
//Serial.println(C1);
//delay(100);
// C2 (3 buttons)
if ( btnState3 == HIGH && btnPressed3 == LOW ) {
C2 = C2 + 1;
btnPressed3 = true;
}
if ( btnState4 == HIGH && btnPressed4 == LOW ) {
C2 = C2 + 1;
btnPressed4 = true;
}
if ( btnState5 == HIGH && btnPressed5 == LOW ) {
C2 = C2 + 1;
btnPressed5 = true;
}
if(C2 == 3){
digitalWrite(ledPin2, HIGH);
}else{
digitalWrite(ledPin2, LOW);
if (currentMillis2 - previousMillis2 >= interval2) {
previousMillis2 = currentMillis2;
C2 = 0;
btnPressed3 = false;
btnPressed4 = false;
btnPressed5 = false;
}
}
//Serial.println(C2);
//delay(100);
// C3 (2 buttons)
if ( btnState6 == HIGH && btnPressed6 == LOW ) {
C3 = C3 + 1;
btnPressed6 = true;
}
if ( btnState7 == HIGH && btnPressed7 == LOW ) {
C3 = C3 + 1;
btnPressed7 = true;
}
if(C3 == 2){
digitalWrite(ledPin3, HIGH);
}else{
digitalWrite(ledPin3, LOW);
// reset to base timer
if (currentMillis3 - previousMillis3 >= interval3) {
previousMillis3 = currentMillis3;
C3 = 0;
btnPressed6 = false;
btnPressed7 = false;
}
}
//Serial.println(C3);
//delay(100);
// C4 (2 buttons)
if ( btnState8 == HIGH && btnPressed8 == LOW ) {
C4 = C4 + 1;
btnPressed8 = true;
}
if ( btnState9 == HIGH && btnPressed9 == LOW ) {
C4 = C4 + 1;
btnPressed9 = true;
}
if(C4 == 2){
digitalWrite(ledPin4, HIGH);
}else{
digitalWrite(ledPin4, LOW);
// reset to base timer
if (currentMillis4 - previousMillis4 >= interval4) {
previousMillis4 = currentMillis4;
C4 = 0;
btnPressed8 = false;
btnPressed9 = false;
}
}
//Serial.println(C4);
//delay(100);
// C5 (3 buttons)
if ( btnState10 == HIGH && btnPressed10 == LOW ) {
C5 = C5 + 1;
btnPressed10 = true;
}
if ( btnState11 == HIGH && btnPressed11 == LOW ) {
C5 = C5 + 1;
btnPressed11 = true;
}
if ( btnState12 == HIGH && btnPressed12 == LOW ) {
C5 = C5 + 1;
btnPressed12 = true;
}
if(C5 == 3){
digitalWrite(ledPin5, HIGH);
}else{
digitalWrite(ledPin5, LOW);
if (currentMillis5 - previousMillis5 >= interval5) {
previousMillis5 = currentMillis5;
C5 = 0;
btnPressed10 = false;
btnPressed11 = false;
btnPressed12 = false;
}
}
Serial.println(C5);
delay(100);
}