-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombination1.ino
98 lines (82 loc) · 2.43 KB
/
combination1.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
#include <Adafruit_NeoPixel.h>
#define PIN 6 // the Data Pin for the strip.
#define NUMPIXELS 300 // how many pixels are on the strip
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int incoming;
void setup() {
// put your setup code here, to run once:
strip1.begin();
strip1.show();
Serial.begin(115200);
}
void loop() {
if (Serial.available() > 0) {
incoming = Serial.read(); // reads the next thing sent on the serial line.
if (incoming == 'a') {
Serial.println ("Auto Enabled!");
}
}
for(int b = 0; b < 4; b++){
blink(0,0,64,500);
}
easter(50,79,100);
for(int b = 0; b < 4; b++){
ripple(0,0,64,6,35);
}
}
void solidColor(int r, int g, int b){
for(int i = 0; i < strip1.numPixels(); i++){
strip1.setPixelColor(i, strip1.Color(r,g,b));
}
strip1.show();
}
void blink(int r, int g, int b, int wait) {
solidColor(r,g,b);
delay(wait);
solidColor(0,0,0);
delay(wait);
}
void easter(int r,int g,int b){
int num = 0;
for(int i = strip1.numPixels(); i > 0; i--){
int R = random(r);
int G = random(g);
int B = random(b);
for(int r = num + 1; r <= i; r++){
strip1.setPixelColor(r, strip1.Color(R,G,B));
strip1.show();
delayMicroseconds(10);
strip1.setPixelColor(r, strip1.Color(0,0,0));
}
strip1.setPixelColor(i, strip1.Color(R,G,B));
for(int k = i - 1; k >= num; k--){
strip1.setPixelColor(k, strip1.Color(R,G,B));
strip1.show();
delayMicroseconds(10);
strip1.setPixelColor(k, strip1.Color(0,0,0));
}
strip1.setPixelColor(num, strip1.Color(R,G,B));
num++;
}
strip1.show();
}
void ripple(int r, int g, int b, byte magnitude, byte wait){
for (int s = (magnitude * -2); s < 0; s++){
if (Serial.available() == 0){
for (int p = 0; p < strip1.numPixels() + (2 * magnitude); p += (2*magnitude)) {
for (int i = 0; i < magnitude; i++){
if ((p+i-s) >= 0 && p+i-s < strip1.numPixels()){
strip1.setPixelColor(p+i-s, strip1.Color((i*r)/magnitude, (i*g)/magnitude, (i*b)/magnitude));
}
}
for (int i = magnitude; i > 0; i--) {
if ((p-s+((magnitude * 2) - i)) >= 0 && (p-s+((magnitude * 2) - i)) < strip1.numPixels()){
strip1.setPixelColor((p-s+((magnitude * 2) - i)), strip1.Color((i*r)/magnitude, (i*g)/magnitude, (i*b)/magnitude));
}
}
}
strip1.show();
delay(wait);
}
}
}