-
Notifications
You must be signed in to change notification settings - Fork 0
/
Homecoming 2024
381 lines (256 loc) · 7.5 KB
/
Homecoming 2024
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
#include <FastLED.h>
#define LED_PIN 7
#define NUM_LEDS 400
int lights[NUM_LEDS + 1];
int colorSelect = 0;
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
FastLED.addLeds<WS2811, LED_PIN, GRB>(leds, NUM_LEDS);
}
void loop() {
Sequence5();
Sequence1();
Sequence3();
Sequence2();
}
void Sequence1() {
int wait = 2500;
int pulse = 2.5;
int repeat = 2;
for (int i = 0; i < repeat; i++) {
SetColor(255, 0, 0);
delay(wait);
ColorClimbUp(pulse, 255,100,0);
delay(wait);
ColorClimbDown(pulse, 255,0,0);
}
}
void Sequence2() {
int wait = 2500;
int pulse = 1.0;
int repeat = 2;
for (int i = 0; i < repeat; i++) {
SetColor(255,0,0);
//Sparkle to yellow
SparkleColorChange(pulse, 255, 100, 0);
delay(wait);
//Sparkle to red
SparkleColorChange(pulse, 255, 0, 0);
delay(wait);
}
}
void Sequence3() {
//TODO: add yellow
int wait = 100;
int repeatRed = 10;
int repeatYellow = 10;
int repeatBoth = 2;
for(int bothLoopVar = 0; bothLoopVar < repeatBoth; bothLoopVar++) {
for(int redLoopVar = 0; redLoopVar < repeatRed; redLoopVar++) {
MixedLights2(50,0,0, 100,0,0, 150,0,0, 200,0,0, 250,0,0);
delay(wait);
MixedLights2(250,0,0, 50,0,0, 100,0,0, 150,0,0, 200,0,0);
delay(wait);
MixedLights2(200,0,0, 250,0,0, 50,0,0, 100,0,0, 150,0,0);
delay(wait);
MixedLights2(150,0,0, 200,0,0, 250,0,0, 50,0,0, 100,0,0);
delay(wait);
MixedLights2(100,0,0, 150,0,0, 200,0,0, 250,0,0, 50,0,0);
delay(wait);
}
for(int yellowLoopVar = 0; yellowLoopVar < repeatYellow; yellowLoopVar++) {
MixedLights2(50,20,0, 100,40,0, 150,60,0, 200,80,0, 250,100,0);
delay(wait);
MixedLights2(250,100,0, 50,20,0, 100,40,0, 150,60,0, 200,80,0);
delay(wait);
MixedLights2(200,80,0, 250,100,0, 50,20,0, 100,40,0, 150,60,0);
delay(wait);
MixedLights2(150,60,0, 200,80,0, 250,100,0, 50,20,0, 100,40,0);
delay(wait);
MixedLights2(100,40,0, 150,60,0, 200,80,0, 250,100,0, 50,20,0);
delay(wait);
}
}
}
void Sequence4() {
int wait = 250;
int repeat = 10;
for(int i = 0; i < repeat; i++) {
MixedLights3(255,0,0, 225,100,0);
delay(wait);
MixedLights3(255,100,0, 255,0,0);
delay(wait);
}
}
void Sequence5() {
int wait = 100; // Speed of movement
int barWidth = 10; // Width of the color bars
int repeat = 250; // NOTE: NUM_LEDS + barWidth; = Total movements needed to wrap around
for (int i = 0; i < repeat; i++) {
// Set the LEDs with alternating red and yellow bars
for (int j = 0; j < NUM_LEDS; j++) {
// Determine the current position in relation to the bar width
int currentPosition = (j + i) % (2 * barWidth);
// If the current position is in the range of the red bar
if (currentPosition < barWidth) {
leds[j] = CRGB(0,255,0); // Set red
} else {
leds[j] = CRGB(100,255,0); // Set yellow
}
}
FastLED.show();
delay(wait);
}
}
void MixedLights2(int red1, int green1, int blue1, int red2, int green2, int blue2, int red3, int green3, int blue3, int red4, int green4, int blue4, int red5, int green5, int blue5) {
for (int place = 0; place < NUM_LEDS; place = place+5) {
leds[place] = CRGB(green1, red1, blue1);
leds[place+1] = CRGB(green2, red2, blue2);
leds[place+2] = CRGB(green3, red3, blue3);
leds[place+3] = CRGB(green4, red4, blue4);
leds[place+4] = CRGB(green5, red5, blue5);
}
FastLED.show();
}
void MixedLights4(
int red1, int green1, int blue1,
int red2, int green2, int blue2,
int red3, int green3, int blue3,
int red4, int green4, int blue4,
int red5, int green5, int blue5,
int red6, int green6, int blue6) {
for (int place = 0; place < NUM_LEDS; place = place+6) {
leds[place] = CRGB(green1, red1, blue1);
leds[place+1] = CRGB(green2, red2, blue2);
leds[place+2] = CRGB(green3, red3, blue3);
leds[place+3] = CRGB(green4, red4, blue4);
leds[place+4] = CRGB(green5, red5, blue5);
leds[place+5] = CRGB(green6, red6, blue6);
}
FastLED.show();
}
void MixedLights1(int red1, int green1, int blue1, int red2, int green2, int blue2, int red3, int green3, int blue3) {
for (int place = 0; place <= NUM_LEDS; place = place+3) {
leds[place] = CRGB(green1, red1, blue1);
leds[place+1] = CRGB(green2, red2, blue2);
leds[place+2] = CRGB(green3, red3, blue3);
}
FastLED.show();
}
void MixedLights3(int red1, int green1, int blue1, int red2, int green2, int blue2) {
for (int place = 0; place <= NUM_LEDS; place = place+3) {
leds[place] = CRGB(green1, red1, blue1);
leds[place+1] = CRGB(green2, red2, blue2);
}
FastLED.show();
}
void ChristmasFade() {
int green = 0;
int red = 0;
int blue = 0;
int pulse = 2.5;
int wait = 1000;
SetColor(255, 0, 0);
delay(wait);
for (int i = 0; i < 255; i++) {
red--;
green++;
SetColor(red, green, blue);
delay(pulse);
}
SetColor(0, 255, 0);
delay(wait);
red = 0;
blue = 0;
green = 255;
for (int i = 0; i < 255; i++) {
red++;
blue++;
SetColor(red, green, blue);
delay(pulse);
}
SetColor(255, 255, 255);
delay(wait);
red = 255;
green = 255;
blue = 255;
for (int i = 0; i < 255; i++) {
green--;
blue--;
SetColor(red, green, blue);
delay(pulse);
}
delay(wait);
}
void SetThreeColors(int topRed, int topGreen, int topBlue, int midRed, int midGreen, int midBlue, int bottomRed, int bottomGreen, int bottomBlue) {
int sectionDivider = NUM_LEDS / 3;
//bottom
for(int place = 0; place <= sectionDivider; place++) {
leds[place] = CRGB(bottomGreen, bottomRed, bottomBlue);
}
FastLED.show();
//middle
for(int place = sectionDivider; place <= sectionDivider * 2; place++) {
leds[place] = CRGB(midGreen, midRed, midBlue);
}
FastLED.show();
//top
for(int place = sectionDivider * 2; place <= (sectionDivider * 3); place++) {
leds[place] = CRGB(topGreen, topRed, topBlue);
}
FastLED.show();
}
void SetColor(int red, int green, int blue) {
//fill
for(int place = 0; place <= NUM_LEDS; place++) {
leds[place] = CRGB(green, red, blue);
}
FastLED.show();
}
void ColorSwitch(int initialRed, int initialGreen, int initialBlue, int newRed, int newGreen, int newBlue) {
//fill
for(int place = 0; place <= NUM_LEDS; place++) {
leds[place] = CRGB(initialGreen, initialRed, initialBlue);
}
FastLED.show();
//newColor
for(int place = 0; place <= NUM_LEDS; place++) {
leds[place] = CRGB(newGreen, newRed, newBlue);
}
FastLED.show();
}
void ColorClimbUp(int pulse, int red, int green, int blue) {
for(int place = 0; place <= NUM_LEDS; place++) {
leds[place] = CRGB(green, red, blue);
FastLED.show();
delay(pulse);
}
}
void ColorClimbDown(int pulse, int red, int green, int blue) {
for(int place = NUM_LEDS; place >= 0; place--) {
leds[place] = CRGB(green, red, blue);
FastLED.show();
delay(pulse);
}
}
void SparkleColorChange(int pulse, int red, int green, int blue) {
//sparkle
for (int i = 0; i <= NUM_LEDS + 1; i++) {
lights[i] = i;
}
size_t n = sizeof(lights) / sizeof(lights[0]);
for (size_t i = 0; i < n - 1; i++) {
size_t j = random(0, n - i);
int t = lights[i];
lights[i] = lights[j];
lights[j] = t;
}
for(int i = 0; i <= NUM_LEDS-1; i++) {
int place = lights[i];
Serial.println(place);
leds[place] = CRGB(green, red, blue);
delay(pulse);
FastLED.show();
}
}