-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRGBW-circular.ino
65 lines (57 loc) · 1.69 KB
/
RGBW-circular.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
// cw coleman neo RGBW circular
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
#define NUM_LEDS 16
#define BRIGHTNESS 25
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
void setup() {
Serial.begin(9600);
#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'
randomSeed(analogRead(0));
}
//set up variables
int red,green,blue,white;
//set first led and total leds
int first = 10;
int leds = 16;
int count = 0;
//The event loop *************************
void loop() {
if (count == 0){
//this sets up the leds for the first time through the loop
red = 0; green = 0; blue = 255; white = 0;
}
red = 255;
if(count % 2 == 0) {red = 0;}
circular(first,leds,red,green,blue,white);
//if (count ==0) delay(3000);
first = first + 1;
if (first > (leds -1)) first = 0;//reset first to 0 if it is greater than the number of leds
count++;
if(count > 1000) count = 1; //never set count to 0
}
// end of the event loop *************************
//red function
void circular(int s, int lds, 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 = 100;// change the delayVal to speed things up
int j;
Serial.println();//debug
for(j = 0; j < 16 ; j++){
Serial.println (s);//debug
strip.setPixelColor(s, strip.Color(r,g,b,w ));
delay(delayVal);
strip.show();
s++; // increase s by 1;
if (s > (lds -1)) { s = 0;}
}
}