-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplit LED string
650 lines (564 loc) · 19.3 KB
/
Split LED string
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#include <FastLED.h>
#include <RBD_Timer.h>
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_WIFI_POINT
#include <WiFi.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "Front House Lights"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 385 bytes
{ 255,3,0,0,0,122,1,16,8,5,3,10,5,6,9,81,1,2,26,129,
0,16,8,11,6,1,37,82,101,100,0,129,0,16,16,14,6,1,247,82,
111,115,101,0,129,0,16,24,24,6,1,233,77,97,103,101,110,116,97,0,
129,0,16,32,16,6,1,218,86,105,111,108,101,116,0,129,0,16,40,12,
6,1,191,66,108,117,101,0,129,0,16,48,16,6,1,165,65,122,117,114,
101,0,129,0,16,56,36,6,1,122,83,112,114,105,110,103,71,114,101,101,
110,0,129,0,16,65,17,6,1,134,71,114,101,101,110,0,129,0,16,73,
18,6,1,94,89,101,108,108,111,119,0,129,0,16,81,21,6,1,2,79,
114,97,110,103,101,0,131,1,1,92,28,6,1,2,31,82,71,66,32,77,
111,100,101,0,131,0,31,92,29,6,2,2,31,67,117,115,116,111,109,32,
77,111,100,101,0,3,10,5,6,9,81,2,2,26,129,0,17,7,30,6,
2,17,82,71,66,32,77,111,100,101,0,129,0,17,15,18,6,2,17,65,
108,108,32,67,111,108,111,117,114,115,0,129,0,17,24,18,6,2,135,67,
104,114,105,115,116,109,97,115,0,129,0,17,32,18,6,2,36,72,97,108,
108,111,119,101,101,110,0,129,0,17,40,18,6,2,17,45,0,129,0,17,
48,18,6,2,17,45,0,129,0,17,56,18,6,2,17,45,0,129,0,17,
64,18,6,2,17,45,0,129,0,17,72,18,6,2,17,45,0,129,0,17,
80,2,6,2,17,45,0,2,1,46,5,13,5,0,134,26,31,31,79,78,
0,79,70,70,0,129,0,43,1,18,3,0,16,83,105,109,112,108,101,32,
77,111,100,101,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t colour_selection; // =0 if select position A, =1 if position B, =2 if position C, ...
uint8_t custom_mode_select; // =0 if select position A, =1 if position B, =2 if position C, ...
uint8_t simple_colour; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
//Light Sensor Data
//#define light_switch_pin 5 //Tx
#define photoresistor_pin 8 //A3
RBD::Timer sensor_read_norm_1;
RBD::Timer sensor_read_norm_2;
int delay_sensor_read_norm = 10000;
int light_raw;
int darkness = 1900;
int light = 2800;
bool light_switch;
bool darkness_state_1;
bool darkness_state_2;
bool darkness_state;
//NeoPixel
#define DATA_PIN1 A2 // Which pin are those Neopixels hook up to?
#define LAMP1 7 //num LEDs in first lamp
#define LAMP2 7
#define LAMP3 7
#define LAMP4 7
#define LAMP5 7
#define NUMBER_OF_FLAMES (LAMP1+LAMP2+LAMP3+LAMP4+LAMP5) // = Number of Lamps * groups of Neopixels. 16 NeoPixel ring, 12 NeoPixel ring, 7 NeoPixel Pad. So 5 lamps of 7 = 35.
#define BRIGHTNESS 100
#define LAMP_SIZE 7
uint8_t whichPalette;
uint8_t numberOfPalettes;
/*
uint8_t LAMP1_LED_ED = LAMP_SIZE-1;
uint8_t LAMP2_LED_ED = LAMP_SIZE*2-1;
uint8_t LAMP3_LED_ED = LAMP_SIZE*3-1;
uint8_t LAMP4_LED_ED = LAMP_SIZE*4-1;
uint8_t LAMP5_LED_ED = NUMBER_OF_FLAMES-1;
uint8_t LAMP1_LED_ST = 0;
uint8_t LAMP2_LED_ST = LAMP_SIZE;
uint8_t LAMP3_LED_ST = LAMP_SIZE*2;
uint8_t LAMP4_LED_ST = LAMP_SIZE*3;
uint8_t LAMP5_LED_ST = LAMP_SIZE*4;
*/
int fade_to_black = 1;
// Define the array of leds
CRGB candles[NUMBER_OF_FLAMES];
CRGB candle1[LAMP1]; //0-6
CRGB candle2[LAMP2]; //7-13
CRGB candle3[LAMP3]; //14-20
CRGB candle4[LAMP4]; //21-27
CRGB candle5[LAMP5]; //28-35
//COLOUR PALLETTES//////////////////////////////////////
/*
DEFINE_GRADIENT_PALETTE(flamecolorsYellow){
0,255,255,0, //yellow
115,255,180,0, //orange
150,210,255,0, //greenwashed yellow
255,255,255,0 //yellow
};
DEFINE_GRADIENT_PALETTE(flamecolorsOrange){
0,255,125,0, //orange
115,255,30,0, //reddish
150,255,170,0, //yellowish
255,255,125,0 //orange
};
DEFINE_GRADIENT_PALETTE(flamecolorsRed){
0,255,0,0, //red
115,255,50,0, //dark orange
150,255,0,50, //pink
255,255,0,0 //red
// remember to set range to 255 not 100. Multiply by 2.55.
};
DEFINE_GRADIENT_PALETTE(flamecolorsRose){
0,255,0,125, //rose
115,255,0,180, //magenta
150,255,0,0, //red
255,255,0,125 //rose
};
DEFINE_GRADIENT_PALETTE(flamecolorsMagenta){
0,255,0,255, //magenta
115,255,0,180, //rose
150,180,0,255, //violet
255,255,0,255 //magenta
};
DEFINE_GRADIENT_PALETTE(flamecolorsViolet){
0,125,0,255, //violet
115,180,0,255, //Magenta
150,40,0,255, //blue
255,125,255,0 //violet
};
DEFINE_GRADIENT_PALETTE(flamecolorsBlue){
0,0,0,255, //blue
115,80,0,255, //violet
150,0,70,255, //azure
255,0,0,255 //blue
};
DEFINE_GRADIENT_PALETTE(flamecolorsAzure){
0,0,125,255, //azure
115,0,0,255, //blue
150,0,255,256, //cyan
255,0,125,255 //azure
};
DEFINE_GRADIENT_PALETTE(flamecolorsCyan){
0,0,255,255, //cyan
115,0,125,255, //azure
150,0,255,125, //turquoise
255,0,255,255 //cyan
};
DEFINE_GRADIENT_PALETTE(flamecolorsTurquoise){
0,0,255,125, //turquoise
115,0,255,255, //cyan
150,0,255,0, //green
255,0,255,125 //turquoise
};
DEFINE_GRADIENT_PALETTE(flamecolorsGreen){
0,0,255,0, //green
115,0,255,125, //turquoise
150,125,255,0, //spring-green
255,0,255,0 //green
};
DEFINE_GRADIENT_PALETTE(flamecolorsSpringGreen){
0,125,255,0, //spring-green
115,25,255,0, //green
150,255,200,0, //yellowish
255,125,255,0 //spring-green
};
DEFINE_GRADIENT_PALETTE(flamecolorsChristmas){
0,255,255,0, //green
85,255,180,0, //white
170,210,255,0, //red
255,255,255,0 //green
};
DEFINE_GRADIENT_PALETTE(flamecolorsHalloween){
0,255,255,0, //orange
85,255,180,0, //violet
170,210,255,0, //ywllow
255,255,255,0 //orange
};
DEFINE_GRADIENT_PALETTE(flamecolorsWhite){
0,150,150,150, //orange
85,180,180,180, //violet
170,150,150,150, //ywllow
255,150,150,150 //orange
};
*/
const TProgmemRGBPalette16 flamecolorsWhite FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsRed FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsRose FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsMagenta FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsViolet FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsBlue FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsAzure FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsCyan FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsTurquoise FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsGreen FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsSpringGreen FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsYellow FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
const TProgmemRGBPalette16 flamecolorsOrange FL_PROGMEM =
{
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey,
CRGB::Grey, CRGB::Grey, CRGB::Grey, CRGB::Grey
};
// Add or remove palette names from this list to control which color
// palettes are used, and in what order.
const TProgmemRGBPalette16* RainbowPaletteList[] = {
&flamecolorsWhite,
/* &flamecolorsRed,
&flamecolorsOrange,
&flamecolorsYellow,
&flamecolorsSpringGreen,
&flamecolorsGreen,
&flamecolorsTurquoise,
&flamecolorsCyan,
&flamecolorsBlue,
&flamecolorsViolet,
&flamecolorsRose,
&flamecolorsMagenta,
*/
};
const TProgmemRGBPalette16* ChristmasPaletteList[] = {
&flamecolorsWhite,
// &flamecolorsRed,
// &flamecolorsGreen,
};
const TProgmemRGBPalette16* HalloweenPaletteList[] = {
// &flamecolorsOrange,
// &flamecolorsRed,
// &flamecolorsYellow,
};
CRGBPalette16 col_palette; //used when all lamps the same colour blend
CRGBPalette16 col_palette1; //used for lamp 1
CRGBPalette16 col_palette2;
CRGBPalette16 col_palette3;
CRGBPalette16 col_palette4;
CRGBPalette16 col_palette5;
///////////////////////////////////////
void setup() {
pinMode(photoresistor_pin, INPUT); // Set the switch pin as input
// pinMode(light_switch_pin, INPUT);
RemoteXY_Init ();
delay(3000); // sets a delay to insure that everything has initalized before proceeding with the setup
Serial.begin(57600); // Set up serial communication at 57600
Serial.println("STARTUP");
FastLED.addLeds<WS2812B,DATA_PIN1,GRB>(candles,NUMBER_OF_FLAMES);
FastLED.setBrightness(BRIGHTNESS);
sensor_read_norm_1.setTimeout(delay_sensor_read_norm);
sensor_read_norm_1.restart();
sensor_read_norm_2.setTimeout(delay_sensor_read_norm);
delay(delay_sensor_read_norm/2);
sensor_read_norm_2.restart();
col_palette = flamecolorsRed;
}
void loop() {
RemoteXY_Handler ();
Daylight_check();
EVERY_N_MILLISECONDS(50){
if(RemoteXY.simple_colour == 1){ //simple colours only
if (RemoteXY.colour_selection == 0) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Red);
}
if (RemoteXY.colour_selection == 1) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::DeepPink);
}
if (RemoteXY.colour_selection == 2) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Magenta);
}
if (RemoteXY.colour_selection == 3) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Purple);
}
if (RemoteXY.colour_selection == 4) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Blue);
}
if (RemoteXY.colour_selection == 5) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Cyan);
}
if (RemoteXY.colour_selection == 6) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Chartreuse);
}
if (RemoteXY.colour_selection == 7) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Green);
}
if (RemoteXY.colour_selection == 8) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Yellow);
}
if (RemoteXY.colour_selection == 9) {
fill_solid(candles,NUMBER_OF_FLAMES,CRGB::Orange);
}
FastLED.setBrightness(BRIGHTNESS);
}
else{
if(darkness_state==0){
if (RemoteXY.custom_mode_select == 0){ //colour palettes selected from page 1
if (RemoteXY.colour_selection == 0) {
col_palette = flamecolorsRed;
}
if (RemoteXY.colour_selection == 1) {
col_palette = flamecolorsRose;
}
if (RemoteXY.colour_selection == 2) {
col_palette = flamecolorsMagenta;
}
if (RemoteXY.colour_selection == 3) {
col_palette = flamecolorsViolet;
}
if (RemoteXY.colour_selection == 4) {
col_palette = flamecolorsBlue;
}
if (RemoteXY.colour_selection == 5) {
col_palette = flamecolorsAzure;
}
if (RemoteXY.colour_selection == 6) {
col_palette = flamecolorsSpringGreen;
}
if (RemoteXY.colour_selection == 7) {
col_palette = flamecolorsGreen;
}
if (RemoteXY.colour_selection == 8) {
col_palette = flamecolorsYellow;
}
if (RemoteXY.colour_selection == 9) {
col_palette = flamecolorsOrange;
}
else {
}
//set new LED colour and brightness.
candles[random8(0,NUMBER_OF_FLAMES-1)] = ColorFromPalette(col_palette, random8(),random8(150,255),LINEARBLEND); //random LED select, random colour from preset palette, random brightness.
}
else{ //colours palettes selected from page 2 -to do later
if (RemoteXY.colour_selection == 0) {
EVERY_N_SECONDS(5);{
//set multiple colour palettes at random
numberOfPalettes = sizeof(RainbowPaletteList) / sizeof(RainbowPaletteList[0]);
whichPalette = random8(0,numberOfPalettes);
col_palette1 = *(RainbowPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette2 = *(RainbowPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette3 = *(RainbowPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette4 = *(RainbowPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette5 = *(RainbowPaletteList[whichPalette]);
}
Colour_lamps();
}
if (RemoteXY.colour_selection == 1) {
EVERY_N_SECONDS(5);{
//set multiple colour palettes at random
numberOfPalettes = sizeof(ChristmasPaletteList) / sizeof(ChristmasPaletteList[0]);
whichPalette = random8(0,numberOfPalettes);
col_palette1 = *(ChristmasPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette2 = *(ChristmasPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette3 = *(ChristmasPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette4 = *(ChristmasPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette5 = *(ChristmasPaletteList[whichPalette]);
}
Colour_lamps();
}
if (RemoteXY.colour_selection == 2) {
EVERY_N_SECONDS(5);{
//set multiple colour palettes at random
numberOfPalettes = sizeof(HalloweenPaletteList) / sizeof(HalloweenPaletteList[0]);
whichPalette = random8(0,numberOfPalettes);
col_palette1 = *(HalloweenPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette2 = *(HalloweenPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette3 = *(HalloweenPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette4 = *(HalloweenPaletteList[whichPalette]);
whichPalette = random8(0,numberOfPalettes);
col_palette5 = *(HalloweenPaletteList[whichPalette]);
}
Colour_lamps();
}
if (RemoteXY.colour_selection == 3) {
CRGBPalette16 col_palette = flamecolorsViolet;
}
if (RemoteXY.colour_selection == 4) {
CRGBPalette16 col_palette = flamecolorsBlue;
}
if (RemoteXY.colour_selection == 5) {
CRGBPalette16 col_palette = flamecolorsAzure;
}
if (RemoteXY.colour_selection == 6) {
CRGBPalette16 col_palette = flamecolorsSpringGreen;
}
if (RemoteXY.colour_selection == 7) {
CRGBPalette16 col_palette = flamecolorsGreen;
}
if (RemoteXY.colour_selection == 8) {
CRGBPalette16 col_palette = flamecolorsYellow;
}
if (RemoteXY.colour_selection == 9) {
CRGBPalette16 col_palette = flamecolorsOrange;
}
else {
}
}
fadeToBlackBy(candles,NUMBER_OF_FLAMES,fade_to_black);
}
else{ //turn off
FastLED.clear();
}
}
}
FastLED.show();
}
void Daylight_check(){
//read sensors and convert -------------------------------------
if(sensor_read_norm_1.isExpired())
{
sensor_read_norm_1.restart();
light_raw=analogRead(photoresistor_pin);
Serial.println(light_raw);
// light_switch=digitalRead(light_switch_pin);
// Serial.print("lightswitch = ");
// Serial.println(light_switch);
if(light_raw<=light)
{
darkness_state_1 = 0; //0 is night, 1 = day
}
else if(light_raw>=darkness)
{
darkness_state_1=1;
}
else
{
}
Serial.print("darkness_state_1 = ");
Serial.println(darkness_state_1);
}
if(sensor_read_norm_2.isExpired())
{
sensor_read_norm_2.restart();
light_raw=analogRead(photoresistor_pin);
Serial.println(light_raw);
// light_switch=digitalRead(light_switch_pin);
// Serial.print("lightswitch = ");
// Serial.println(light_switch);
if(light_raw<=light)
{
darkness_state_2 = 0;
}
else if(light_raw>=darkness)
{
darkness_state_2=1;
}
else
{
}
Serial.print("darkness_state_2 = ");
Serial.println(darkness_state_2);
if(darkness_state_1==darkness_state_2) //true if both reads say its dark or both say it's light
{
if(darkness_state_1==1) //true if day
{
darkness_state=1;
}
else{
darkness_state=0;
}
}
else{
}
Serial.print("darkness_state = ");
Serial.println(darkness_state);
}
}
void Colour_lamps(){
//colour lamp LEDS
candle1[random8(0,LAMP1-1)] = ColorFromPalette(col_palette1, random8(),random8(150,255),LINEARBLEND);
candle2[random8(0,LAMP1-1)] = ColorFromPalette(col_palette2, random8(),random8(150,255),LINEARBLEND);
candle3[random8(0,LAMP1-1)] = ColorFromPalette(col_palette3, random8(),random8(150,255),LINEARBLEND);
candle4[random8(0,LAMP1-1)] = ColorFromPalette(col_palette4, random8(),random8(150,255),LINEARBLEND);
candle5[random8(0,LAMP1-1)] = ColorFromPalette(col_palette5, random8(),random8(150,255),LINEARBLEND);
//copy individual candle1+ to candles
for(uint8_t i=0; i<candle1;i++){candles[i]=candle1[i];}
for(uint8_t i=0; i<candle2;i++){candles[i+7]=candle2[i];}
for(uint8_t i=0; i<candle3;i++){candles[i+14]=candle3[i];}
for(uint8_t i=0; i<candle4;i++){candles[i+21]=candle4[i];}
for(uint8_t i=0; i<candle5;i++){candles[i+28]=candle5[i];}
}