-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolton_circle_w_stop
157 lines (139 loc) · 4.46 KB
/
colton_circle_w_stop
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
// cw coleman neo RGBW circular
// http://www.letsarduino.com/project-13-angle-indicator-with-servo-motor-and-5-buttons-an-arduino/
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
#define NUM_LEDS 24
#define BRIGHTNESS 25
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
// define input pins
const int button2 = 2; // the number of the pushbutton pin
const int button3 = 3; // the number of the pushbutton pin
const int button4 = 4;
const int button5 = 5;
const int led13 = 24; // the number of the LED pin
//button state
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
void setup() {
Serial.begin(9600);
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
strip.setBrightness(BRIGHTNESS);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
// initialize the LED pin as an output:
pinMode(led13, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(button2, INPUT);
pinMode(button3, INPUT);
}
//set up variables
int red,green,blue,white;
//set first led and total leds
int first = 10;
int last = 24;
int count;
int val = LOW;
//The event loop *************************
void loop() {
// button code
val = digitalRead(button2);
if (val == HIGH)
{
first = 0; last = 11; red = 255, green = 0; blue = 0; white = 30;
thestop(first,last,red,green,blue,white);
val = HIGH;
// first = 0; last = 11; red = 255, green = 0; blue = 0; white = 30;
// circular(first,last,red,green,blue,white);
val = LOW;
// first = 12; last = 24; red = 0, green = 255; blue = 0; white = 30;
// circular(first,last,red,green,blue,white);
// val = LOW;
first = 0; last = 23; red = 0, green = 0; blue = 0; white = 0;
circular(first,last,red,green,blue,white);
}
val = digitalRead(button3);
if (val == HIGH)
{
first = 0; last = 11; red = 0, green = 0; blue = 255; white = 30;
circular(first,last,red,green,blue,white);
val = LOW;
first = 0; last = 24; red = 0, green = 0; blue = 0; white = 0;
circular(first,last,red,green,blue,white);
}
val = digitalRead(button4);
if (val == HIGH)
{
first = 12; last = 24; red = 0, green = 0; blue = 0; white = 30;
circular(first,last,red,green,blue,white);
val = LOW;
first = 0; last = 24; red = 0, green = 0; blue = 0; white = 0;
circular(first,last,red,green,blue,white);
}
val = digitalRead(button5);
if (val == HIGH)
{
first = 24; last = 12; red = 0, green = 255; blue = 0; white = 30;
circular(first,last,red,green,blue,white);
val = LOW;
first = 0; last = 24; red = 0, green = 0; blue = 0; white = 0;
circular(first,last,red,green,blue,white);
}
//end button code
}
// end of the event loop *************************
// circular(first,last,red,green,blue,white);
void circular(int s, int e, int r,int g,int b,int w){
// s:start lds:the number of leds r:red g:green b:blue w:white
int delayVal = 10;// change the delayVal to speed things up
int j;
//Serial.println();//debug
if(s < e){
for(j = s; j < (e+1) ; j++){
// Serial.println (s);//debug
strip.setPixelColor(j, strip.Color(r,g,b,w ));
delay(delayVal);
strip.show();
}
}
else {
for(j = s; j > (e-1) ; j--){
// Serial.println (s);//debugz
strip.setPixelColor(j, strip.Color(r,g,b,w ));
delay(delayVal);
strip.show();
}
}
}// end circular
void thestop(int s, int e, int r,int g,int b,int w){
// s:start lds:the number of leds r:red g:green b:blue w:white
int delayVal = 10;// change the delayVal to speed things up
int j,k = 23;
//Serial.println();//debug
if(s < e){
for(j = s; j < (e+1) ; j++){
// Serial.println (s);//debug
strip.setPixelColor(j, strip.Color(r,g,b,w ));
strip.setPixelColor(k, strip.Color(r,g,b,w ));
k--;
delay(delayVal);
strip.show();
}
}
else {
for(j = s; j > (e-1) ; j--){
// Serial.println (s);//debugz
strip.setPixelColor(j, strip.Color(r,g,b,w ));
delay(delayVal);
strip.show();
}
}
}// end circular