-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFredLightingCopy.ino
More file actions
145 lines (101 loc) · 2.66 KB
/
FredLightingCopy.ino
File metadata and controls
145 lines (101 loc) · 2.66 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
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
//Absolute version on the collar as of 3-24-2026!
#include <Adafruit_NeoPixel.h>
#define PIN 3
#define NUM_OF_LEDS 56
Adafruit_NeoPixel strip = Adafruit_NeoPixel(56, PIN, NEO_GRB + NEO_KHZ800);
int randomNumber;
int red[56];
int green[56];
int blue[56];
int sensorPin = A0;
int sensorValue = 0;
int select = 0;
int i,j;
int element[8][3];
void setup() {
// put your setup code here, to run once:
strip.begin();
strip.show(); // Initialize all pixels to 'off'
randomSeed(analogRead(A1));
}
boolean check(){
boolean change = false;
int sensorValue=analogRead(sensorPin);
if (sensorValue < 512) {select++; change = true;}
if (select > 4) select = 0;
delay(67);
return change;
}
void clearStrip(){
for (int i = 0; i < NUM_OF_LEDS; i++){
strip.setPixelColor(i, 0, 0, 0);
}
strip.show();
}
void greenChaserTask(int i){
int chaser_len = 5;
strip.setPixelColor(i, 0, 125, 0);
if (i < chaser_len) {
strip.setPixelColor((i-chaser_len+56)%56, 0, 0, 0);
}
strip.setPixelColor(i-chaser_len, 0, 0, 0);
strip.setBrightness(140);
strip.show();
}
void randomLightsTask(int i){
if (i == 0){
for (int r = 0; r < 56; r++) {
red[r] = random(255);
}
for (int g = 0; g < 56; g++) {
green[g] = random(255);
}
for (int b = 0; b < 56; b++) {
blue[b] = random(255);
}
}
strip.setPixelColor(i, red[i], green[i], blue[i]);
for (int r = 0; r < 56; r++) {
red[r] -= 4;
}
for (int g = 0; g < 56; g++) {
green[g] -= 4;
}
for (int b = 0; b < 56; b++) {
blue[b] -= 4;
}
strip.setBrightness(140);
strip.show();
}
void colorBandTask(int i, int r, int g, int b){
strip.setPixelColor(i, r, g, b);
strip.setBrightness(140);
strip.show();
}
void greenBandTask(int i){
colorBandTask(i, 0, 255, 0);
}
void redBandTask(int i){
colorBandTask(i, 255, 0, 0);
}
void blueBandTask(int i){
colorBandTask(i, 0, 0, 255);
}
void loop() {
// put your main code here, to run repeatedly:
/* Read Sensor
Sensor value will be 1023 when open,
will drop to 78 when blocked
When sensor is blocked, advance slection by 1*/
/* ALL GREEN */
for (i = 0; i < NUM_OF_LEDS; i ++){
if (select == 0) greenChaserTask(i);
else if (select == 1) randomLightsTask(i);
else if (select == 2) greenBandTask(i);
else if (select == 3) blueBandTask(i);
else if (select == 4) redBandTask(i);
if (check()) {clearStrip(); break;}
delay(20);
}
}
int cigarettes = 500;