-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmart-led.ino
301 lines (186 loc) · 4.7 KB
/
smart-led.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
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
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
/* IR Codes*/
#define IR_BPLUS 0xF700FF
#define IR_BMINUS 0xF7807F
#define IR_OFF 0xF740BF
#define IR_ON 0xF7C03F
#define IR_R 0xF720DF
#define IR_G 0xF7A05F
#define IR_B 0xF7609F
#define IR_W 0xF7E01F
#define IR_B1 0xF710EF
#define IR_B2 0xF7906F
#define IR_B3 0xF750AF
#define IR_FLASH 0xF7D02F
#define IR_B4 0xF730CF
#define IR_B5 0xF7B04F
#define IR_B6 0xF7708F
#define IR_STROBE 0xF7F00F
#define IR_B7 0xF708F7
#define IR_B8 0xF78877
#define IR_B9 0xF748B7
#define IR_FADE 0xF7C837
#define IR_B10 0xF728D7
#define IR_B11 0xF7A857
#define IR_B12 0xF76897
#define IR_SMOOTH 0xF7E817
const int irPin = 4;
IRsend irsend(irPin);
// Wifi creds and auth key for blynk.
char ssid[] = "";
char password[] = "";
char auth[] = "";
void setup(){
Serial.begin(9600);
irsend.begin();
Blynk.begin(auth, ssid, password);
}
// Power - on/off
BLYNK_WRITE(V0){
int pinValue = param.asInt();
if(pinValue == 1){
Serial.println("Power On");
irsend.sendNEC(IR_OFF, 32);
irsend.sendNEC(IR_OFF, 32);
irsend.sendNEC(IR_OFF, 32);
delay(1000);
}
if(pinValue == 0){
Serial.println("Power off");
irsend.sendNEC(IR_ON, 32);
irsend.sendNEC(IR_ON, 32);
irsend.sendNEC(IR_ON, 32);
delay(1000);
}
}
// RGB
BLYNK_WRITE(V1){
int pinValue = param.asInt();
if(pinValue == 1){
Serial.println("Red");
irsend.sendNEC(IR_R, 32);
delay(1000);
}
if(pinValue == 2){
Serial.println("color from red family");
irsend.sendNEC(IR_B1 , 32);
delay(1000);
}
if(pinValue == 3){
Serial.println("color from red family");
irsend.sendNEC(IR_B4 , 32);
delay(1000);
}
if(pinValue == 4){
Serial.println("color from red family");
irsend.sendNEC(IR_B7 , 32);
delay(1000);
}
if(pinValue == 5){
Serial.println("color from red family");
irsend.sendNEC(IR_B10 , 32);
delay(1000);
}
if(pinValue == 6){
Serial.println("Green");
irsend.sendNEC(IR_G, 32);
delay(1000);
}
if(pinValue == 7){
Serial.println("color from green family");
irsend.sendNEC(IR_B2 , 32);
delay(1000);
}
if(pinValue == 8){
Serial.println("color from green family");
irsend.sendNEC(IR_B5 , 32);
delay(1000);
}
if(pinValue == 9){
Serial.println("color from green family");
irsend.sendNEC(IR_B8 , 32);
delay(1000);
}
if(pinValue == 10){
Serial.println("color from green family");
irsend.sendNEC(IR_B11 , 32);
delay(1000);
}
if(pinValue == 11){
irsend.sendNEC(IR_B, 32);
delay(1000);
}
if(pinValue == 12){
Serial.println("color from blue family");
irsend.sendNEC(IR_B2 , 32);
delay(1000);
}
if(pinValue == 13){
Serial.println("color from blue family");
irsend.sendNEC(IR_B6 , 32);
delay(1000);
}
if(pinValue == 14){
Serial.println("color from blue family");
irsend.sendNEC(IR_B9 , 32);
delay(1000);
}
if(pinValue == 15){
Serial.println("color from blue family");
irsend.sendNEC(IR_B12 , 32);
delay(1000);
}
if(pinValue == 16){
Serial.println("color from White family");
irsend.sendNEC(IR_W , 32);
delay(1000);
}
}
// Brightness Plus
BLYNK_WRITE(V2){
int pinValue = param.asInt();
if(pinValue == 1){
Serial.println("Brightnes plus");
irsend.sendNEC(IR_BPLUS , 32);
delay(1000);
}
}
// Brightness minus
BLYNK_WRITE(V3){
int pinValue = param.asInt();
if(pinValue == 1){
Serial.println("Brightnes minus");
irsend.sendNEC(IR_BMINUS , 32);
delay(1000);
}
}
// Patterns
BLYNK_WRITE(V4){
int pinValue = param.asInt();
if(pinValue == 1){
Serial.println("FLASH");
irsend.sendNEC(IR_FLASH , 32);
delay(1000);
}
if(pinValue == 2){
Serial.println("STROBE");
irsend.sendNEC(IR_STROBE , 32);
delay(1000);
}
if(pinValue == 3){
Serial.println("FADE");
irsend.sendNEC(IR_FADE , 32);
delay(1000);
}
if(pinValue == 4){
Serial.println("SMOOTH");
irsend.sendNEC(IR_SMOOTH , 32);
delay(1000);
}
}
void loop(){
Blynk.run();
}