-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorPulser.ino
More file actions
78 lines (70 loc) · 2.01 KB
/
ColorPulser.ino
File metadata and controls
78 lines (70 loc) · 2.01 KB
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
#include "FastLED.h"
#define NUM_STRIPS 4
#define NUM_LEDS_PER_STRIP 150
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
uint16_t iterations = 40;
uint16_t delayOfTranistions = 0;
void setup() {
delay(1000);//Safe Gaurd
Serial.begin(9600);
Serial.println("It has begun...");
FastLED.addLeds<WS2812, 4, GRB>(leds[0], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812, 5, GRB>(leds[1], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812, 6, GRB>(leds[2], NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2812, 7, GRB>(leds[3], NUM_LEDS_PER_STRIP);
}
void loop()
{
Serial.println("loop");
ColorPulserWrapper();
}
void ColorPulserWrapper() {
for (int i = 0; i < iterations; i++) {
Serial.println(i, DEC);
Serial.println("ColorPulserWrapper");
ColorPulser(ChangeColor(), 1);
}
}
void ColorPulser(CRGB color, uint8_t wait) {
Serial.println("ColorPulser");
random16_add_entropy(random());
int trailOfPulse = random8(4, 12);
int distanceApart = random8(5, 20);
int amountOfPulses = random8(4, 25);
int lengthOfLoop = NUM_LEDS_PER_STRIP + trailOfPulse + (distanceApart*amountOfPulses)
for (int i = 0; i < lengthOfLoop; i++) {
//Redraw the pulses
for (int strip = 0; strip < NUM_STRIPS; strip++) {
for (int x = 0; x < trailOfPulse; x++){
for (int y = 0; y < amountOfPulses; y++){
int item = ((i - x) - (distanceApart * y));
if (item >= 0 && (item < NUM_LEDS_PER_STRIP)){
leds[strip][item] = color;
leds[strip][item].fadeToBlackBy(x * (int)(256 / trailOfPulse));
}
}
}
}
//Show
FastLED.show();
delay(GetDelay());
//Dim everything
for (int strip = 0; strip < NUM_STRIPS; strip++) {
for (int x = 0; x < trailOfPulse; x++){
for (int y = 0; y < amountOfPulses; y++){
int item = ((i - x) - (distanceApart * y));
if (item >= 0 && (item < NUM_LEDS_PER_STRIP)){
leds[strip][item].fadeToBlackBy(210);
}
}
}
}
}
}
uint16_t GetDelay() {
return delayOfTranistions;
}
CRGB ChangeColor(){
random16_add_entropy(random());
return CRGB(random8(), random8(), random8());
}