-
Notifications
You must be signed in to change notification settings - Fork 0
/
LEDLIGHT.ino
186 lines (175 loc) · 4.59 KB
/
LEDLIGHT.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
#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 16
#define DATA_PIN 3
#define EEPROM_address 0
#define EEPROM_address_1 4
CRGB leds[NUM_LEDS];
byte themode=0;
int thecount=0;
CRGBPalette16 currentPalette;
TBlendType currentBlending;
void setup() {
delay( 500 ); // power-up safety delay
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
themode = EEPROM.read(EEPROM_address);
int lockemode = EEPROM.read(EEPROM_address_1);
if(lockemode!=1) {
themode++;
}
if( themode > 5 ) {
themode = 0;
}
EEPROM.write(EEPROM_address, themode);
EEPROM.write(EEPROM_address_1, 0);
FastLED.setBrightness( 255 );
for( int i = 0; i <= themode; i++) {
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(150);
fill_solid( leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(100);
}
//fill_solid( leds, NUM_LEDS, CRGB::Black);
//FastLED.show();
delay(1000);
EEPROM.write(EEPROM_address_1, 1);
}
void loop() {
switch ( themode ) {
case 0:
FastLED.setBrightness( 64 );
fill_solid( leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(60000);
break;
case 1:
FastLED.setBrightness( 255 );
fill_solid( leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(60000);
break;
case 2:
thecount++;
if(thecount>=360) {
thecount=0;
}
FastLED.setBrightness( ( sin( PI * thecount / 180 ) + 1 ) * 127 );
//fill_solid( leds, NUM_LEDS, CRGB::White);
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(10);
break;
case 3:
FastLED.setBrightness( 255 );
fill_solid( leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(400);
fill_solid( leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(1400);
break;
case 4:
FastLED.setBrightness( 255 );
/*
thecount++;
if(thecount>=NUM_LEDS) {
thecount=0;
}
fill_solid( leds, NUM_LEDS, CRGB::Black);
leds[thecount] = CRGB::White;
FastLED.show();
delay(100);
*/
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(400);
fill_solid( leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
fill_solid( leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(50);
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(400);
break;
case 5:
FastLED.setBrightness( 255 );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(50);
break;
default:
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(60000);
break;
}
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, 255, currentBlending);
colorIndex += 1;
}
}