-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclick_tracker.ino
76 lines (61 loc) · 1.33 KB
/
click_tracker.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
const int button1Pin = 12;
const int button2Pin = 11;
const int corpPins[] = {7,8,9};
const int runnerPins[] = {3,4,5,6};
int litCorpPins = 0, litRunnerPins = 0;
void setup()
{
int index;
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
for(index = 0; index < 3; index++)
{
pinMode(corpPins[index], OUTPUT);
}
for(index = 0; index < 4; index++)
{
pinMode(runnerPins[index], OUTPUT);
}
}
void loop()
{
int button1State, button2State, index;
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
if (button1State == LOW )
{
if (litCorpPins < 3)
{
litCorpPins = litCorpPins + 1;
for(index = litCorpPins; index != 0; index--)
{
digitalWrite(corpPins[index-1], HIGH);
}
} else {
litCorpPins = 0;
for(index = 0; index < 4; index ++)
{
digitalWrite(corpPins[index], LOW);
}
}
delay(250);
}
if (button2State == LOW )
{
if (litRunnerPins < 4)
{
litRunnerPins = litRunnerPins + 1;
for(index = litRunnerPins; index != 0; index--)
{
digitalWrite(runnerPins[index-1], HIGH);
}
} else {
litRunnerPins = 0;
for(index = 0; index < 4; index ++)
{
digitalWrite(runnerPins[index], LOW);
}
}
delay(250);
}
}