-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOscillate.ino
More file actions
87 lines (76 loc) · 2.06 KB
/
Oscillate.ino
File metadata and controls
87 lines (76 loc) · 2.06 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
79
80
81
82
83
84
85
86
87
#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");
OscialateWrapper();
}
void OscialateWrapper() {
Serial.println("OscialateWrapper");
int middle = NUM_LEDS_PER_STRIP / 2;
ResetAll();
FastLED.show(); // display this frame
delay(GetDelay());
for (int y = 0; y < iterations; y++) {
Serial.println("Oscialate");
Oscialate(middle);
}
}
void Oscialate(int middle) {
CRGB wcolor = CRGB::WhiteSmoke;
int lengthOfOscilation = random8(16, middle - 1);
//Got Out
CRGB color = ChangeColor();
for (int z = 0; z < lengthOfOscilation; z++) {
for (int i = 0; i < NUM_STRIPS; i++) {
leds[i][middle - z] = wcolor;
leds[i][middle + z] = wcolor;
}
FastLED.show(); // display this frame
delay(GetDelay());
for (int i = 0; i < NUM_STRIPS; i++) {
leds[i][middle - z] = color;
leds[i][middle + z] = color;
}
}
//Go In
for (int z = lengthOfOscilation; z > 0; z--) {
for (int i = 0; i < NUM_STRIPS; i++) {
leds[i][middle - z] = wcolor;
leds[i][middle + z] = wcolor;
}
FastLED.show(); // display this frame
FastLED.delay(GetDelay());
for (int i = 0; i < NUM_STRIPS; i++) {
leds[i][middle - z] = color;
leds[i][middle + z] = color;
}
}
}
uint16_t GetDelay() {
return delayOfTranistions;
}
CRGB ChangeColor(){
random16_add_entropy(random());
return CRGB(random8(), random8(), random8());
}
void ResetAll(){
for (int x = 0; x < NUM_STRIPS; x++) {
for (int y = 0; y < NUM_LEDS_PER_STRIP; y++) {
leds[x][y] = CRGB::Black;
}
}
}