-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpomodoro.ino
108 lines (92 loc) · 1.96 KB
/
pomodoro.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
#define Buton 8
#define LED0 2
#define LED1 3
#define LED2 4
#define LED3 5
#define LED4 6
#define LEDS 5
#define LEDS_DELAY_MS 400
#define LEDS_STARTUP_DELAY 500
#define SEC_UNIT_MS 1000
#define POMODORO_25 true
#define POMODORO_5 false
int leds[] = { LED0,LED1,LED2,LED3,LED4 };
bool state=false;
void MinDelay(int minutes);
void pomodoro_ready(int _leds[], int _delay);
void first_open(int leds[]);
void start_leds_open(int Leds[], int _delay);
void start_leds_close(int Leds[], int _delay);
void all_leds_open(int leds[]);
void setup() {
pinMode(Buton, INPUT);
for (int i = 0; i<LEDS; i++) {
pinMode(leds[i], OUTPUT);
}
}
void loop()
{
if (digitalRead(Buton) == 1) {
first_open(leds);
delay(LEDS_DELAY_MS);
pomodoro_ready(leds, LEDS_STARTUP_DELAY);
delay(LEDS_DELAY_MS);
while (digitalRead(Buton) != 0);
digitalWrite(LED4, LOW);
if (state == POMODORO_25)
{
for (size_t i = 0; i < 5; i++)
{
MinDelay(5);
digitalWrite(leds[4 - i], LOW);
}
while (digitalRead(Buton) == 0);
state = POMODORO_5;
//pomodoro25
}
else if (state == POMODORO_5)
{
for (size_t i = 0; i < 5; i++)
{
MinDelay(1);
digitalWrite(leds[4 - i], LOW);
}
state = POMODORO_25;
//pomodoro5
}
}
void first_open(int leds[]) {
}
void start_leds_open(int leds[], int _delay) {
for (int i = 0; i<LEDS; i++) {
digitalWrite(leds[i], HIGH);
delay(_delay);
}
}
void start_leds_close(int _leds[], int _delay) {
for (int i = 0; i < LEDS; i++) {
digitalWrite(leds[i], LOW);
delay(_delay);
}
}
void pomodoro_ready(int _leds[], int _delay) {
start_leds_open(_leds, _delay);
delay(LEDS_DELAY_MS);
start_leds_close(_leds, _delay);
}
void MinDelay(int minutes) {
for (int sec = 0; sec<minutes; sec++) {
for (int ms = 0; ms<60; ms++) {
delay(SEC_UNIT_MS);
}
}
}
void all_leds_open(int leds[]) {
for (int i=0; i < LEDS; i++) {
digitalWrite(leds[i], HIGH);
}
for (int i=0; i < LEDS; i++) {
digitalWrite(leds[i], LOW);
MinDelay(0);
}
}