/
function_RGBW.ino
53 lines (40 loc) · 1.06 KB
/
function_RGBW.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
// RGBW (Red Green Blue White Neo-Pixel starter code
// 16 LEDS For Loop
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
#define NUM_LEDS 16
#define BRIGHTNESS 50
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
void setup() {
Serial.begin(115200);
strip.setBrightness(BRIGHTNESS);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
// Initialize some variables for the void loop()
int red = 0, green= 0, blue = 0, white = 10;
int wait = 500;
int led = 0;
int i;
void loop() {
for ( led = 0; led < 16; led++){
strip.setPixelColor(led, red, green , blue, white);
}//end of for loop
strip.show();
delay(wait);
red = red + 8;
green = green + 16;
blue = blue + 32;
white = white + 1;
if (red > 255) red = 0;
if (green > 255) green = 0;
if (blue > 255) blue = 0;
if (white > 50) white = 0;
if (red < 0) red = 255;
if (green < 0) green = 255;
if (blue < 0) blue = 255;
if (white < 0 ) white = 50;
}