-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathledhiaketa.ino
94 lines (75 loc) · 1.6 KB
/
ledhiaketa.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
#define NEOPIXEL_DATA_PIN 5
#define NUM_LEDS 53
#include <FastLED.h>
CRGB leds[NUM_LEDS];
const int a_btn = 6;
const int b_btn = 7;
unsigned int a_score = 0;
unsigned int b_score = 0;
unsigned int a_clicks = 0;
unsigned int b_clicks = 0;
unsigned long t = 0;
unsigned int gHue = 0;
int mode = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
FastLED.addLeds<NEOPIXEL, NEOPIXEL_DATA_PIN>(leds, NUM_LEDS);
startCountdown();
countSetup();
}
unsigned long last_evt_t = 0;
void loop() {
// put your main code here, to run repeatedly:
/*if (millis() - t >= 100) {
t = millis();
Serial.print(a_score);
Serial.print("\t");
Serial.println(b_score);
}*/
unsigned long t = millis();
if (mode == 0) {
EVERY_N_MILLISECONDS( 1 ) {
gHue++; // slowly cycle the "base color" through the rainbow
}
fill_rainbow( leds, NUM_LEDS, gHue, 7);
FastLED.show();
if (!digitalRead(a_btn) || !digitalRead(b_btn)) {
mode = 3;
startCountdown();
last_evt_t = t;
a_clicks = 0;
b_clicks = 0;
}
}
// Playing
if (mode == 1) {
countScore();
drawBoard();
if (a_score >= NUM_LEDS) {
mode = 2;
startWinnerAnimation(1);
last_evt_t = t;
}
if (b_score >= NUM_LEDS) {
mode = 2;
startWinnerAnimation(2);
last_evt_t = t;
}
}
//
if (mode == 2) {
drawWinnerAnimation();
if (t - last_evt_t >= 5000) {
mode = 0;
last_evt_t = t;
}
}
//Countdown
if (mode == 3) {
if (drawCountdown()) {
mode = 1;
last_evt_t = t;
}
}
}