-
Notifications
You must be signed in to change notification settings - Fork 0
/
jingle-bells-sync.ino
126 lines (102 loc) · 1.87 KB
/
jingle-bells-sync.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
int relay_1 = 7;
int relay_2 = 8;
int relay_3 = 9;
int relay_4 = 10;
int estrelas = relay_2;
int amarelas = relay_3;
int coloridas = relay_4;
void setup() {
configInitialState();
jingleBells();
jingleBells();
// second 8
turnOnAll();
delay(18000);
// second 26
// Oh ...
turnOffAll();
delay(1500);
// second 27,5
jingleBells();
jingleBells();
// second 35,5
// Hey ...
turnOffAll();
delay(1000);
// second 36,5
jingleBells();
jingleBells();
// second 44,5
turnOffAll();
delay(5000);
// second 49,5
turnOnAll();
delay(18000);
// 1 min 7,5 sec
// Oh ...
turnOffAll();
delay(1500);
// 1 min 9 sec
jingleBells();
jingleBells();
// 1 min 17 sec
// Hey ...
turnOffAll();
delay(1000);
// 1 min 18 sec
jingleBells();
jingleBells();
delay(1000);
// 1 min 27 sec
turnOn(estrelas);
delay(2000);
turnOn(amarelas);
delay(2000);
turnOn(coloridas);
delay(3000);
turnOffAll();
// 1 min 34 sec
delay(1000);
jingleBells();
jingleBells();
}
void configInitialState() {
// Set RelayPin as an output pin
pinMode(relay_1, OUTPUT);
pinMode(relay_2, OUTPUT);
pinMode(relay_3, OUTPUT);
pinMode(relay_4, OUTPUT);
// Set all realys off initially
digitalWrite(relay_1, HIGH);
digitalWrite(relay_2, HIGH);
digitalWrite(relay_3, HIGH);
digitalWrite(relay_4, HIGH);
}
void jingleBells() {
turnOn(estrelas);
delay(1000);
turnOn(amarelas);
delay(1000);
turnOn(coloridas);
delay(1500);
turnOffAll();
delay(500);
}
void turnOn(int relay) {
digitalWrite(relay, LOW);
}
void turnOnAll() {
digitalWrite(estrelas, LOW);
digitalWrite(amarelas, LOW);
digitalWrite(coloridas, LOW);
}
void turnOff(int relay) {
digitalWrite(relay, HIGH);
}
void turnOffAll() {
digitalWrite(estrelas, HIGH);
digitalWrite(amarelas, HIGH);
digitalWrite(coloridas, HIGH);
}
void loop() {
}