#include "LPD8806.h"
#include
// Example to control LPD8806-based RGB LED Modules in a strip
//digital in pin 11
//clock in pin 13
/*****************************************************************************/
// The LED strips are 32 LEDs per meter but you can extend/cut the strip
LPD8806 strip = LPD8806(32); // Set the first variable to the NUMBER of pixels. 32 = 32 pixels in a row
void setup() {
// Start up the LED strip
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop() {
randomSparkleUpSegment(strip.Color(25,0,0),15,10,101,152); //color, density, delay, low point, high point
turnSegmentOn(strip.Color(25,0,0),1000, 101, 152); //color, delay, start of segment, end of segment
randomSparkleUpSegment(strip.Color(0,25,0),15,10,0,100); //color, density, delay, low point, high point
turnSegmentOn(strip.Color(0,25,0),200,0,100); //color, delay, start of segment, end of segment
delay(500);
turnAllOff;
fillUpTheStar(strip.Color(0,0,25),30); //color, delay
fillUpCenterStar(strip.Color(0,0,25),30); //color, delay
fillUpTheStar(strip.Color(25,0,0),30); //color, delay
fillUpCenterStar(strip.Color(25,0,0),30); //color, delay
fillUpTheStar(strip.Color(0,25,0),30); //color, delay
fillUpCenterStar(strip.Color(0,25,0),30); //color, delay
fillUpTheStar(strip.Color(25,25,25),30); //color, delay
fillUpCenterStar(strip.Color(25,25,25),30); //color, delay
turnAllOn(strip.Color(25,0,0),200); //color, delay - turn all pixels one color
dither(strip.Color(0,25,0), 50); //color, delay - random fills up the strip
fadeDown(0,25,0,30); //red, green, blue, delay - fade down all pixels one color
dither(strip.Color(25,0,0), 50); //color, delay - random fills up the strip
fadeDown(25,0,0,30); //red, green, blue, delay - fade down all pixels one color
turnAllOn(strip.Color(25,0,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(0,25,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(25,0,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(0,25,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(25,0,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(0,25,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(25,0,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(0,25,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(25,0,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(0,25,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(25,0,0),400); //color, delay - turn all pixels one color
turnAllOn(strip.Color(0,25,0),400); //color, delay - turn all pixels one color
chaseBetweenLToH(strip.Color(25,25,25),20,0,100); //color, delay, low, high - chase led between two locations progressing up the chain
chaseBetweenHToL(strip.Color(25,25,25),20,103,152); //color, delay, low, high - chase led between two locations progressing down the chain
turnAllOff(); //turn all pixels off
fadeUp(25,0,0,20); //red, green, blue, delay - fade up all pixels one color
fadeDown(25,0,0,20); //red, green, blue, delay - fade down all pixels one color
fadeUp(0,25,0,20); //red, green, blue, delay - fade up all pixels one color
fadeDown(0,25,0,20); //red, green, blue, delay - fade down all pixels one color
turnAllOff();
/// strobe effect r/g rg
randomSparkle(strip.Color(25,0,0),20, 30); //color, density, delay - random sparkles in one color
randomSparkle(strip.Color(0,25,0),20, 30); //color, density, delay - random sparkles in one color
twoColorSparkle(strip.Color(25,0,0), strip.Color(0,25,0), 20, 10); //color 1, color 2, density, delay - random sparkles in two colors
rainbow(20);
turnAllOff();
randomColorSparkle(30); //delay - random color sparkles
turnAllOn(strip.Color(0,0,25),1000); //color, delay - turn all pixels one color
chaseBetweenLToH(strip.Color(25,25,25),1,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
chaseBetweenLToH(strip.Color(0,25,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
chaseBetweenHToL(strip.Color(25,0,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing down the chain
chaseBetweenHToL(strip.Color(0,25,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing down the chain
chaseToCenter(strip.Color(25,0,0),25,1,0,159); //color, number of leds in line, delay, low, high - chase lines to the center
chasePastCenter(strip.Color(25,0,0),25,1,0,159); //color, number of leds in line, delay, low, high - chase lines past the center
chaseBetweenLToH(strip.Color(50,50,25),1,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
chaseBetweenLToH(strip.Color(25,0,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
chaseBetweenLToH(strip.Color(0,25,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
chaseLineHToL(strip.Color(25,0,0),50,0,0,159); //color, number of leds in line, delay, low, high - chase leds in a line progressing up the chain
chaseLineLToH(strip.Color(0,25,0),50,0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
rainbowCycle(0); // make it go through the cycle fairly fast
turnAllOff();
//red and green segments around perimeter, center blue
int i;
for(i=1; i<=4; i++){
delay(1000);
fadeDown(25,25,25,40); //red, green, blue, delay - fade down all pixels one color
}
turnAllOn(strip.Color(0,0,25),200);
dither(strip.Color(25,0,0), 20); //color, delay - random fills up the strip
fadeDown(25,0,0,30); //red, green, blue, delay - fade down all pixels one color
turnSegmentOn(strip.Color(0,0,25),10,104,159); //color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,0,25),10,0,103); //color, delay, start of segment, end of segment
chaseUpTheStar(strip.Color(25,0,0),30); //color, delay
chaseUpCenterStar(strip.Color(25,0,0),30); //color, delay
turnSegmentOn(strip.Color(0,25,0),10,0,159); //color, delay, start of segment, end of segment
chaseUpTheStar(strip.Color(25,0,0),30); //color, delay
turnAllOff();
fillUpTheStar(strip.Color(25,0,0),30); //color, delay
fillUpCenterStar(strip.Color(0,25,0), 30); //color, delay
fillUpTheStar(strip.Color(0,25,0),30); //color, delay
fillUpCenterStar(strip.Color(25,0,0),30); //color, delay
fillUpTheStar(strip.Color(25,25,25),30); //color, delay
fillUpCenterStar(strip.Color(25,25,25),30); //color, delay
turnAllOff();
dither(strip.Color(0,25,25), 10); //color, delay - random fills up the strip
fadeDown(0,25,25,20); //red, green, blue, delay - fade down all pixels one color
turnAllOff();
scanner(25,0,0,10); //red, green, blue, delay
turnAllOff();
wave(strip.Color(25,0,0),5,0,200); //color, cycles, delay, repetitions
fadeDown(25,0,0,20); //red, green, blue, delay - fade down all pixels one color
wave(strip.Color(0,25,0),5,0,200); //color, cycles, delay, repetitions
turnAllOff();
randomSparkleUpStrip(strip.Color(25,25,25),15,10); //color, density, wait
turnAllOn(strip.Color(25,25,25),500);
fadeDown(25,25,25,20); //red, green, blue, delay - fade down all pixels one color
randomSparkleUpStrip(strip.Color(20,20,25),15,10);
turnAllOn(strip.Color(20,20,25),500);
fadeDown(20,20,25,20); //red, green, blue, delay - fade down all pixels one color
randomSparkleUpStrip(strip.Color(25,50,25),15,10);
turnAllOn(strip.Color(25,50,25),500);
fadeDown(25,50,25,20); //red, green, blue, delay - fade down all pixels one color
randomSparkleUpStrip(strip.Color(20,25,39),15,10);
turnAllOn(strip.Color(20,127,39),500);
fadeDown(20,25,39,20); //red, green, blue, delay - fade down all pixels one color
randomSparkleUpStrip(strip.Color(10,10,25),15,10);
turnAllOn(strip.Color(10,10,25),500);
fadeDown(10,10,25,20); //red, green, blue, delay - fade down all pixels one color
turnAllOn(strip.Color(0,25,0),400);
chaseBetweenLToH(strip.Color(25,0,0),20,0,100); //color, delay, low, high - chase led between two locations progressing up the chain
chaseBetweenHToL(strip.Color(25,0,0),20,103,152); //color, delay, low, high - chase led between two locations progressing down the chain
//green to red wave
wave(strip.Color(0,25,0),5,0,100); //color, cycles, delay, repetitions
wave(strip.Color(20,25,0),10,0,50); //color, cycles, delay, repetitions
wave(strip.Color(40,25,0),15,0,50); //color, cycles, delay, repetitions
wave(strip.Color(80,25,0),20,0,50); //color, cycles, delay, repetitions
wave(strip.Color(25,25,0),25,0,50); //color, cycles, delay, repetitions
wave(strip.Color(25,80,0),35,0,50); //color, cycles, delay, repetitions
wave(strip.Color(25,40,0),35,0,50); //color, cycles, delay, repetitions
wave(strip.Color(25,20,0),35,0,50); //color, cycles, delay, repetitions
wave(strip.Color(25,0,0),35,0,100); //color, cycles, delay, repetitions
wave(strip.Color(25,0,0),35,0,50); //color, cycles, delay, repetitions
turnAllOff();
wave(strip.Color(0,25,0),35,0,100); //color, cycles, delay, repetitions
wave(strip.Color(20,107,0),35,0,50); //color, cycles, delay, repetitions
wave(strip.Color(40,87,0),35,0,50); //color, cycles, delay, repetitions
wave(strip.Color(80,47,0),30,0,50); //color, cycles, delay, repetitions
wave(strip.Color(107,27,0),20,0,100); //color, cycles, delay, repetitions
wave(strip.Color(25,0,0),5,0,200); //color, cycles, delay, repetitions
int j;
for(j=1; j<=15; j++){
turnSegmentOn(strip.Color(0,0,25),0, 60, 100);//red 1 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,0,0),0, 147, 152); //blue 1 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,0,0),200, 103, 109); //blue 1 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,25,0),0, 44, 59); //red 4 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,25,0),0, 110, 121); //blue 4 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,0,25),0, 0, 15); //red 2 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,0,0),200, 135, 146); //blue 2 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,25,0),0, 60, 100); //red 1 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,25,0),0, 147, 152); // blue 1 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,25,0),0, 103, 109); //blue 1 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,0,25),0, 16, 43); //red 3 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,0,0),200, 122, 134); //blue 3 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,25,0),0, 0, 15); //red 2 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,25,0),0, 135, 146); //blue 2 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,0,25),0, 44, 59); //red 4 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,0,0),200, 110, 121); //blue 4 on - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(25,25,0),0, 16, 43); //red 3 off - color, delay, start of segment, end of segment
turnSegmentOn(strip.Color(0,25,0),0, 122, 134); //blue 3 off - color, delay, start of segment, end of segment
}
chaseMultipleLinesLToH(10,10,0,152); //number of leds in line, delay, low, high - chase multiple lines progressing up the chain
}
// An "ordered dither" fills every pixel in a sequence that looks
// sparkly and almost random, but actually follows a specific order.
void dither(uint32_t c, uint8_t wait) {
// Determine highest bit needed to represent pixel index
int hiBit = 0;
int n = strip.numPixels() - 1;
for(int bit=1; bit < 0x8000; bit <<= 1) {
if(n & bit) hiBit = bit;
}
int bit, reverse;
for(int i=0; i<(hiBit << 1); i++) {
// Reverse the bits in i to create ordered dither:
reverse = 0;
for(bit=1; bit <= hiBit; bit <<= 1) {
reverse <<= 1;
if(i & bit) reverse |= 1;
}
strip.setPixelColor(reverse, c);
strip.show();
delay(wait);
}
delay(250); // Hold image for 1/4 sec
}
// "Larson scanner" = Cylon/KITT bouncing light effect
void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait) {
int i, j, pos, dir;
pos = 0;
dir = 1;
for(i=0; i<((strip.numPixels()-1) * 8); i++) {
// Draw 5 pixels centered on pos. setPixelColor() will clip
// any pixels off the ends of the strip, no worries there.
// we'll make the colors dimmer at the edges for a nice pulse
// look
strip.setPixelColor(pos - 2, strip.Color(r/4, g/4, b/4));
strip.setPixelColor(pos - 1, strip.Color(r/2, g/2, b/2));
strip.setPixelColor(pos, strip.Color(r, g, b));
strip.setPixelColor(pos + 1, strip.Color(r/2, g/2, b/2));
strip.setPixelColor(pos + 2, strip.Color(r/4, g/4, b/4));
strip.show();
delay(wait);
// If we wanted to be sneaky we could erase just the tail end
// pixel, but it's much easier just to erase the whole thing
// and draw a new one next time.
for(j=-2; j<= 2; j++)
strip.setPixelColor(pos+j, strip.Color(0,0,0));
// Bounce off ends of strip
pos += dir;
if(pos < 0) {
pos = 1;
dir = -dir;
} else if(pos >= strip.numPixels()) {
pos = strip.numPixels() - 2;
dir = -dir;
}
}
}
// Sine wave effect
#define PI 3.14159265
void wave(uint32_t c, int cycles, uint8_t wait, int repetitions) {
float y;
byte r, g, b, r2, g2, b2;
// Need to decompose color into its r, g, b elements
g = (c >> 16) & 0x7f;
r = (c >> 8) & 0x7f;
b = c & 0x7f;
for(int x=0; x {
for(int i=0; i y = sin(PI * (float)cycles * (float)(x + i) / (float)strip.numPixels());
y = 1.0 - y; // Translate Y to 0.0 (top) to 1.0 (center)
r2 = (byte)((float)r * y);
g2 = (byte)((float)g * y);
b2 = (byte)((float)b * y);
strip.setPixelColor(i, r2, g2, b2);
}
strip.show();
delay(wait);
}
}
void chaseUpTheStar(uint32_t c, uint8_t wait) {
int i,j;
strip.setPixelColor(80, c);
delay(wait);
strip.setPixelColor(80, strip.Color(0,0,0));
for (i = 1; i <= 20; i++) {
strip.setPixelColor(80+i, c);
strip.setPixelColor(80-i, c);
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(80+i, strip.Color(0,0,0));
strip.setPixelColor(80-i, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
for (j=0; j<=29; j++) {
strip.setPixelColor(j, c);
strip.setPixelColor(59-j, c);
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(j, strip.Color(0,0,0));
strip.setPixelColor(59-j, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
}
void chaseUpCenterStar(uint32_t c, uint8_t wait) {
int i,j;
for (i = 1; i <= 6; i++) {
strip.setPixelColor(146+i, c);
strip.setPixelColor(147-i, c);
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(146+i, strip.Color(0,0,0));
strip.setPixelColor(147-i, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
for (j=0; j<=18; j++) {
strip.setPixelColor(103+j, c);
strip.setPixelColor(140-j, c);
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(103+j, strip.Color(0,0,0));
strip.setPixelColor(140-j, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
}
void fillUpTheStar(uint32_t c, uint8_t wait) {
int i,j;
strip.setPixelColor(80, c);
delay(wait);
for (i = 1; i <= 20; i++) {
strip.setPixelColor(80+i, c);
strip.setPixelColor(80-i, c);
strip.show(); // write all the pixels out
delay(wait);
}
for (j=0; j<=29; j++) {
strip.setPixelColor(j, c);
strip.setPixelColor(59-j, c);
strip.show(); // write all the pixels out
delay(wait);
}
}
void fillUpCenterStar(uint32_t c, uint8_t wait) {
int i,j;
for (i = 1; i <= 6; i++) {
strip.setPixelColor(146+i, c);
strip.setPixelColor(147-i, c);
strip.show(); // write all the pixels out
delay(wait);
}
for (j=0; j<=18; j++) {
strip.setPixelColor(103+j, c);
strip.setPixelColor(140-j, c);
strip.show(); // write all the pixels out
delay(wait);
}
}
void chaseBetweenLToH(uint32_t c, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i;
for (i = pointL; i <= pointH; i++) {
strip.setPixelColor(i, c);
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(i, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
}
void chaseBetweenHToL(uint32_t c, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i;
for (i = pointH; i >= pointL; i--) {
strip.setPixelColor(i, c);
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(i, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
}
void chaseLineLToH(uint32_t c, uint8_t lineNumber, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i, j;
for(i = pointL; i < pointH+lineNumber; i++) {
for(j = 0; j < lineNumber; j++) {
strip.setPixelColor(i-j, c);
}
strip.show(); // write all the pixels out
delay(wait);
turnAllOff();
}
}
void chaseLineHToL(uint32_t c, uint8_t lineNumber, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i, j;
for(i = pointH; i > pointL; i--) {
for(j = 0; j strip.setPixelColor(i+j, c);
}
strip.show(); // write all the pixels out
delay(wait);
turnAllOff();
}
}
void chaseToCenter(uint32_t c, uint8_t lineNumber, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i, j, k;
i = pointL;
k = pointH;
while(i < k && k > i) {
for(j = 0; j < lineNumber; j++) {
strip.setPixelColor(i-j, c);
strip.setPixelColor(k+j, c);
}
strip.show(); // write all the pixels out
delay(wait);
i++;
k--;
turnAllOff();
}
}
void chasePastCenter(uint32_t c, uint8_t lineNumber, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i, j, k;
i = pointL;
k = pointH;
while(i < pointH && k > pointL) {
for(j = 0; j < lineNumber; j++) {
strip.setPixelColor(i-j, c);
strip.setPixelColor(k+j, c);
}
strip.show(); // write all the pixels out
delay(wait);
i++;
k--;
turnAllOff();
}
}
void turnAllOn(uint32_t c, uint32_t wait) {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c); // turn all pixels on
}
strip.show(); // write all the pixels out
delay(wait);
}
void turnSegmentOn(uint32_t c, uint32_t wait, uint8_t startofseg, uint8_t endofseg) {
int i;
for (i=startofseg; i <= endofseg; i++) {
strip.setPixelColor(i, c); // turn all pixels on
}
strip.show(); // write all the pixels out
delay(wait);
}
void fadeUpSeg(uint32_t r, uint32_t g, uint32_t b, uint32_t wait, uint8_t startofseg, uint8_t endofseg) {
int i, j;
for (j=0; j <= 100; j++) {
for (i=startofseg; i<=endofseg; i++) {
strip.setPixelColor(i, strip.Color((r*j)/100,(g*j)/100,(b*j)/100));
}
strip.show();
}
delay(wait);
}
void fadeDownSeg(uint32_t r, uint32_t g, uint32_t b, uint32_t wait, uint8_t startofseg, uint8_t endofseg) {
int i, j;
for (j=100; j >= 0; j--) {
for (i=startofseg; i<=endofseg; i++) {
strip.setPixelColor(i, strip.Color((r*j)/100,(g*j)/100,(b*j)/100)); // turn all pixels on
}
strip.show();
}
delay(wait);
}
void fadeUp(uint32_t r, uint32_t g, uint32_t b, uint32_t wait) {
int i, j;
for (j=0; j <= 100; j++) {
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color((r*j)/100,(g*j)/100,(b*j)/100));
}
strip.show();
}
delay(wait);
}
void fadeDown(uint32_t r, uint32_t g, uint32_t b, uint32_t wait) {
int i, j;
for (j=100; j >= 0; j--) {
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color((r*j)/100,(g*j)/100,(b*j)/100)); // turn all pixels on
}
strip.show();
}
delay(wait);
}
void chaseMultipleLinesLToH(uint8_t lineNumber, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i, j;
for(i = pointL; i <= pointH; i++) {
for(j = 0; j < lineNumber; j++) {
strip.setPixelColor(i, strip.Color(0,0,127));
strip.setPixelColor(i+j+(2*lineNumber), strip.Color(25,0,0));
strip.setPixelColor(i+j+(3*lineNumber), strip.Color(0,25,0));
strip.setPixelColor(i+j+(4*lineNumber), strip.Color(25,25,0));
strip.setPixelColor(i+j+(5*lineNumber), strip.Color(0,25,25));
strip.setPixelColor(i+j+(6*lineNumber), strip.Color(25,0,25));
strip.setPixelColor(i+j+(7*lineNumber), strip.Color(0,0,25));
strip.setPixelColor(i+j+(8*lineNumber), strip.Color(25,0,0));
strip.setPixelColor(i+j+(9*lineNumber), strip.Color(0,0,0));
}
strip.show(); // write all the pixels out
delay(wait);
}
}
void turnAllOff() {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0); // turn all pixels off
}
strip.show(); // write all the pixels out
}
void randomSparkleUpSegment(uint32_t c, uint32_t density, uint8_t wait, uint8_t pointL, uint8_t pointH) {
int i,j,location;
for (j=pointL; j<=pointH; j++) {
for (i=0; i <= density; i++) {
location = random(pointL,j);
strip.setPixelColor(location, c);
}
strip.show(); // write all the pixels out
delay(wait);
turnAllOff();
strip.show(); // write all the pixels out
}
}
void randomSparkleUpStrip(uint32_t c, uint32_t density, uint8_t wait) {
int i,j,location;
for (j=density; j for (i=0; i <= density; i++) {
location = random(0,j);
strip.setPixelColor(location, c);
}
strip.show(); // write all the pixels out
delay(wait);
turnAllOff();
strip.show(); // write all the pixels out
}
}
void randomSparkle(uint32_t c, uint32_t density, uint8_t wait) {
int i,j,location;
for (j=0; j < 200; j++) {
for (i=0; i <= density; i++) {
location = random(0,strip.numPixels()); //random location in first 5th of strip
strip.setPixelColor(location, c);
}
strip.show(); // write all the pixels out
delay(wait);
turnAllOff();
strip.show(); // write all the pixels out
}
}
void randomColorSparkle(uint8_t wait) {
int i;
int location1, location2, location3, location4, location5;
int color1, color2, color3;
for (i=0; i < 200; i++) {
location1 = random(0,32); //random location in first 5th of strip
location2 = random(33,64); //random location in 2nd 5th of strip
location3 = random(65,96); //random location in 3rd 5th of strip
location4 = random(97,128); //random location in 4th 5th of strip
location5 = random(129,159); //randon location in last 5th of strip
color1 = random(25);
color2 = random(25);
color3 = random(25);
strip.setPixelColor(location1, strip.Color(color1,color2,0));
strip.setPixelColor(location2, strip.Color(color3,0,color1));
strip.setPixelColor(location3, strip.Color(0,color2,color3));
strip.setPixelColor(location4, strip.Color(color1,color2,0));
strip.setPixelColor(location5, strip.Color(color3,0,color1));
strip.show(); // write all the pixels out
delay(wait);
strip.setPixelColor(location1, strip.Color(0,0,0));
strip.setPixelColor(location2, strip.Color(0,0,0));
strip.setPixelColor(location3, strip.Color(0,0,0));
strip.setPixelColor(location4, strip.Color(0,0,0));
strip.setPixelColor(location5, strip.Color(0,0,0));
strip.show(); // write all the pixels out
}
}
void twoColorSparkle(uint32_t c1, uint32_t c2, uint32_t density, uint8_t wait) {
int i,j,location1,location2;
for (j=0; j < 200; j++) {
for (i=0; i <= density; i++) {
location1 = random(0,strip.numPixels()); //random location number 1
location2 = random(0,strip.numPixels()); //random location number 2
strip.setPixelColor(location1, c1);
strip.setPixelColor(location2, c2);
}
strip.show(); // write all the pixels out
delay(wait);
turnAllOff();
strip.show(); // write all the pixels out
}
}
void rainbow(uint8_t wait) {
int i, j;
for (j=0; j < 384; j++) { // 3 cycles of all 384 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel( (i + j) % 384));
}
strip.show(); // write all the pixels out
delay(wait);
}
}
// Slightly different, this one makes the rainbow wheel equally distributed
// along the chain
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j=0; j < 384 * 5; j++) { // 5 cycles of all 384 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
// tricky math! we use each pixel as a fraction of the full 384-color wheel
// (thats the i / strip.numPixels() part)
// Then add in j which makes the colors go around per pixel
// the % 384 is to make the wheel cycle around
strip.setPixelColor(i, Wheel( ((i * 384 / strip.numPixels()) + j) % 384) );
}
strip.show(); // write all the pixels out
delay(wait);
}
}
// fill the dots one after the other with said color
// good for testing purposes
void colorWipe(uint32_t c, uint8_t wait) {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
// Chase a dot down the strip
// good for testing purposes
void colorChase(uint32_t c, uint8_t wait) {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0); // turn all pixels off
}
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
if (i == 0) {
strip.setPixelColor(strip.numPixels()-1, 0);
} else {
strip.setPixelColor(i-1, 0);
}
strip.show();
delay(wait);
}
}
/* Helper functions */
//Input a value 0 to 384 to get a color value.
//The colours are a transition r - g -b - back to r
uint32_t Wheel(uint16_t WheelPos)
{
byte r, g, b;
switch(WheelPos / 128)
{
case 0:
r = 25 - WheelPos % 128; //Red down
g = WheelPos % 128; // Green up
b = 0; //blue off
break;
case 1:
g = 25 - WheelPos % 128; //green down
b = WheelPos % 128; //blue up
r = 0; //red off
break;
case 2:
b = 25 - WheelPos % 128; //blue down
r = WheelPos % 128; //red up
g = 0; //green off
break;
}
return(strip.Color(r,g,b));
}
9 Comments
5 years ago
Looks funny, good job!
10 years ago on Introduction
Sorry for the late reply. The only libraries I included was LPD8806.h and
10 years ago on Introduction
I just recieved my light strip do I have to include LPD8806.h and .cpp?
11 years ago on Introduction
great work! have you worn this in vegas yet?
Reply 11 years ago on Introduction
Not yet but a great idea! Thank you!
11 years ago on Introduction
Thank you all for the great comments!!!!!
11 years ago on Introduction
I think Its a very original an funny costume! well done!!!
11 years ago on Introduction
Interesting project. Thanks for sharing.
11 years ago on Introduction
Bravo!