LPD8806 Christmas Star Project

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

LPD8806 Christmas Star Project

Postby skibum » Tue Nov 22, 2011 2:03 am

Check out my first Arduino/LED strip project.

http://www.youtube.com/watch?v=sykPb2Ivr04
skibum
 
Posts: 9
Joined: Mon Oct 24, 2011 2:21 pm

Re: LPD8806 Christmas Star Project

Postby adafruit » Tue Nov 22, 2011 1:44 pm

Nice work! it looks great, we'll post this up :)
User avatar
adafruit
 
Posts: 10485
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: LPD8806 Christmas Star Project

Postby mjoehr » Sun Nov 27, 2011 3:21 pm

Hi

Wow, cool project! Do you share the code to other people? I have built also a xmas-star with 5m LED strip and need some more code examples to create nice pattern. For example, how can i realize rainbow color change for all LEDs at the same time?

thx!
mjoehr
 
Posts: 1
Joined: Sun Nov 27, 2011 3:05 pm
Location: Bern/Switzerland

Re: LPD8806 Christmas Star Project

Postby Cranium » Sun Nov 27, 2011 11:30 pm

Nice job! Looks great!
Cranium
 
Posts: 20
Joined: Tue Oct 25, 2011 7:08 am

Re: LPD8806 Christmas Star Project

Postby dom89 » Wed Nov 30, 2011 8:05 pm

I am interested in using some of your effects as well, specifically the ones at timestamps

0:49
1:27
1:49
2:05
2:44

Would you mind sharing your code?
dom89
 
Posts: 29
Joined: Sun Nov 06, 2011 1:32 am

Re: LPD8806 Christmas Star Project

Postby skibum » Thu Dec 01, 2011 11:08 am

I'd be happy to share the code. I'm just not sure the best way to do that. If you send me a PM with your email address I will send you the code. Unless there is a better way to do it?

Skibum
skibum
 
Posts: 9
Joined: Mon Oct 24, 2011 2:21 pm

Re: LPD8806 Christmas Star Project

Postby adafruit_support_bill » Thu Dec 01, 2011 12:03 pm

If you want to share with everyone :) , click the "code" button at the top of the message editing window and just paste your code in there.
User avatar
adafruit_support_bill
 
Posts: 15957
Joined: Sat Feb 07, 2009 9:11 am

Re: LPD8806 Christmas Star Project

Postby dom89 » Thu Dec 01, 2011 8:17 pm

Adafruit, if there isn't a place already, could there be a place where people can paste their code to share with others? I am sure there are many patterns out there that some people think of and it would be really cool for others to have a place to add patterns to their project
dom89
 
Posts: 29
Joined: Sun Nov 06, 2011 1:32 am

Re: LPD8806 Christmas Star Project

Postby adafruit » Fri Dec 02, 2011 10:56 am

right now, the forum is the best place, we're trying to make a collaborative project space but its taking some time :mrgreen:
User avatar
adafruit
 
Posts: 10485
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: LPD8806 Christmas Star Project

Postby nahiko » Fri Dec 02, 2011 1:07 pm

Hey very very nice!!
nahiko
 
Posts: 24
Joined: Thu Nov 03, 2011 6:42 am

Re: LPD8806 Christmas Star Project

Postby wbp » Sun Dec 04, 2011 3:30 pm

I want to build one of these! How many meters of LED lights did you use? Please do post the code if you would.
Thanks!
William
User avatar
wbp
 
Posts: 149
Joined: Mon Mar 07, 2011 12:18 pm

Re: LPD8806 Christmas Star Project

Postby jn_austin » Mon Dec 05, 2011 6:27 pm

I like this! Congrats on getting it all running.
jn_austin
 
Posts: 7
Joined: Tue Nov 22, 2011 9:43 pm

Re: LPD8806 Christmas Star Project

Postby dom89 » Mon Dec 05, 2011 7:42 pm

I PMed skibum and he emailed me the code. since he said he is willing to share the code, I will post it up for him

Code: Select all
#include "LPD8806.h"
#include <SPI.h>

// Example to control LPD8806-based RGB LED Modules in a strip

/*****************************************************************************/


// Set the first variable to the NUMBER of pixels. 32 = 32 pixels in a row
// The LED strips are 32 LEDs per meter but you can extend/cut the strip
LPD8806 strip = LPD8806(160);

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(127,0,0),15,10,101,152); //color, density, delay, low point, high point
  turnSegmentOn(strip.Color(127,0,0),1000, 101, 152); //color, delay, start of segment, end of segment
  randomSparkleUpSegment(strip.Color(0,127,0),15,10,0,100); //color, density, delay, low point, high point
  turnSegmentOn(strip.Color(0,127,0),200,0,100); //color, delay, start of segment, end of segment
  delay(500);
  turnAllOff;
  fillUpTheStar(strip.Color(0,0,127),30); //color, delay
  fillUpCenterStar(strip.Color(0,0,127),30); //color, delay
  fillUpTheStar(strip.Color(127,0,0),30); //color, delay
  fillUpCenterStar(strip.Color(127,0,0),30); //color, delay
  fillUpTheStar(strip.Color(0,127,0),30); //color, delay
  fillUpCenterStar(strip.Color(0,127,0),30); //color, delay
  fillUpTheStar(strip.Color(127,127,127),30); //color, delay
  fillUpCenterStar(strip.Color(127,127,127),30); //color, delay
 
  turnAllOn(strip.Color(127,0,0),200); //color, delay - turn all pixels one color
  dither(strip.Color(0,127,0), 20); //color, delay - random fills up the strip
  fadeDown(0,127,0,30); //red, green, blue, delay - fade down all pixels one color
  dither(strip.Color(127,0,0), 20); //color, delay - random fills up the strip
  fadeDown(127,0,0,30); //red, green, blue, delay - fade down all pixels one color
   
  turnAllOn(strip.Color(127,0,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(0,127,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(127,0,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(0,127,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(127,0,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(0,127,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(127,0,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(0,127,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(127,0,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(0,127,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(127,0,0),400); //color, delay - turn all pixels one color
  turnAllOn(strip.Color(0,127,0),400); //color, delay - turn all pixels one color
  chaseBetweenLToH(strip.Color(127,127,127),20,0,100); //color, delay, low, high - chase led between two locations progressing up the chain
  chaseBetweenHToL(strip.Color(127,127,127),20,103,152); //color, delay, low, high - chase led between two locations progressing down the chain
 
  turnAllOff(); //turn all pixels off
  fadeUp(127,0,0,20); //red, green, blue, delay - fade up all pixels one color
  fadeDown(127,0,0,20); //red, green, blue, delay - fade down all pixels one color
  fadeUp(0,127,0,20); //red, green, blue, delay - fade up all pixels one color
  fadeDown(0,127,0,20); //red, green, blue, delay - fade down all pixels one color
  turnAllOff();
  randomSparkle(strip.Color(127,0,0),80, 30); //color, density, delay - random sparkles in one color
  randomSparkle(strip.Color(0,127,0),80, 30); //color, density, delay - random sparkles in one color
  twoColorSparkle(strip.Color(127,0,0), strip.Color(0,127,0), 30, 10); //color 1, color 2, density, delay - random sparkles in two colors

  rainbow(20);
  turnAllOff();

  randomColorSparkle(10); //delay - random color sparkles
 
  turnAllOn(strip.Color(0,0,127),1000); //color, delay - turn all pixels one color
  chaseBetweenLToH(strip.Color(127,127,127),1,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
  chaseBetweenLToH(strip.Color(0,127,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
  chaseBetweenHToL(strip.Color(127,0,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing down the chain
  chaseBetweenHToL(strip.Color(0,127,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing down the chain
  chaseToCenter(strip.Color(127,0,0),25,1,0,159); //color, number of leds in line, delay, low, high - chase lines to the center
  chasePastCenter(strip.Color(127,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,127),1,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
  chaseBetweenLToH(strip.Color(127,0,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
  chaseBetweenLToH(strip.Color(0,127,0),0,0,159); //color, delay, low, high - chase leds between two locations progressing up the chain
  chaseLineHToL(strip.Color(127,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,127,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++){
  turnSegmentOn(strip.Color(0,0,127),200, 0, 159); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 81, 100); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),200, 0, 7); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 8, 15); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),200, 16, 29); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 30, 43); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),200, 44, 51); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 52, 59); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),200, 60, 80); //color, delay, start of segment, end of segment
  delay(1000);
  fadeDown(127,127,127,40); //red, green, blue, delay - fade down all pixels one color
  }
 
  turnAllOn(strip.Color(0,0,127),200);
  dither(strip.Color(127,0,0), 20); //color, delay - random fills up the strip
  fadeDown(127,0,0,30); //red, green, blue, delay - fade down all pixels one color
 
  turnSegmentOn(strip.Color(0,0,127),10,104,159); //color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),10,0,103); //color, delay, start of segment, end of segment
  chaseUpTheStar(strip.Color(127,0,0),30); //color, delay
  chaseUpCenterStar(strip.Color(127,0,0),30); //color, delay
  turnSegmentOn(strip.Color(0,127,0),10,0,159); //color, delay, start of segment, end of segment
  chaseUpTheStar(strip.Color(127,0,0),30); //color, delay
  turnAllOff();
 
  fillUpTheStar(strip.Color(127,0,0),30); //color, delay
  fillUpCenterStar(strip.Color(0,127,0), 30); //color, delay
  fillUpTheStar(strip.Color(0,127,0),30); //color, delay
  fillUpCenterStar(strip.Color(127,0,0),30); //color, delay
  fillUpTheStar(strip.Color(127,127,127),30); //color, delay
  fillUpCenterStar(strip.Color(127,127,127),30); //color, delay
 
  turnAllOff();
  dither(strip.Color(0,127,127), 10); //color, delay - random fills up the strip
  fadeDown(0,127,127,20); //red, green, blue, delay - fade down all pixels one color
  turnAllOff();
  scanner(127,0,0,0); //red, green, blue, delay
  turnAllOff();
  wave(strip.Color(127,0,0),5,0,200); //color, cycles, delay, repetitions
  fadeDown(127,0,0,20); //red, green, blue, delay - fade down all pixels one color
  wave(strip.Color(0,127,0),5,0,200); //color, cycles, delay, repetitions
  turnAllOff();
 
 
  randomSparkleUpStrip(strip.Color(127,127,127),15,10); //color, density, wait
  turnAllOn(strip.Color(127,127,127),500);
  fadeDown(127,127,127,20); //red, green, blue, delay - fade down all pixels one color
  randomSparkleUpStrip(strip.Color(20,20,127),15,10);
  turnAllOn(strip.Color(20,20,127),500);
  fadeDown(20,20,127,20); //red, green, blue, delay - fade down all pixels one color
  randomSparkleUpStrip(strip.Color(127,50,127),15,10);
  turnAllOn(strip.Color(127,50,127),500);
  fadeDown(127,50,127,20); //red, green, blue, delay - fade down all pixels one color
  randomSparkleUpStrip(strip.Color(20,127,39),15,10);
  turnAllOn(strip.Color(20,127,39),500);
  fadeDown(20,127,39,20); //red, green, blue, delay - fade down all pixels one color
  randomSparkleUpStrip(strip.Color(10,10,127),15,10);
  turnAllOn(strip.Color(10,10,127),500);
  fadeDown(10,10,127,20); //red, green, blue, delay - fade down all pixels one color

  turnAllOn(strip.Color(0,127,0),400);
  chaseBetweenLToH(strip.Color(127,0,0),20,0,100); //color, delay, low, high - chase led between two locations progressing up the chain
  chaseBetweenHToL(strip.Color(127,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,127,0),5,0,100); //color, cycles, delay, repetitions
  wave(strip.Color(20,127,0),10,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(40,127,0),15,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(80,127,0),20,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(127,127,0),25,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(127,80,0),35,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(127,40,0),45,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(127,20,0),55,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(127,0,0),65,0,100); //color, cycles, delay, repetitions
  wave(strip.Color(127,0,0),65,0,50); //color, cycles, delay, repetitions
 
  turnAllOff();

  wave(strip.Color(0,127,0),60,0,100); //color, cycles, delay, repetitions
  wave(strip.Color(20,107,0),50,0,50); //color, cycles, delay, repetitions
  wave(strip.Color(40,87,0),40,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(127,0,0),5,0,200); //color, cycles, delay, repetitions
 

//Sides Rotating Around Star
  int j;
  for(j=1; j<=15; j++){
  turnSegmentOn(strip.Color(0,0,127),0, 60, 100);//red 1 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),0, 147, 152); //blue 1 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 103, 109); //blue 1 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 44, 59); //red 4 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 110, 121); //blue 4 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),0, 0, 15); //red 2 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 135, 146); //blue 2 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 60, 100); //red 1 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 147, 152); // blue 1 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 103, 109); //blue 1 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),0, 16, 43); //red 3 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 122, 134); //blue 3 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 0, 15); //red 2 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 135, 146); //blue 2 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),0, 44, 59); //red 4 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),200, 110, 121); //blue 4 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 16, 43); //red 3 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 122, 134); //blue 3 off - color, delay, start of segment, end of segment
  }
 
 
   //Sides Rotating Around Star
  int k;
  for(k=1; k<=15; k++){
  turnSegmentOn(strip.Color(127,0,0),0, 60, 100);//blue 1 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),0, 147, 152); //red 1 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),200, 103, 109); //red 1 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 44, 59); //blue 4 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 110, 121); //red 4 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),0, 0, 15); //blue 2 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),200, 135, 146); //red 2 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 60, 100); //blue 1 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 147, 152); // red 1 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 103, 109); //red 1 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),0, 16, 43); //blue 3 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),200, 122, 134); //red 3 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 0, 15); //blue 2 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 135, 146); //red 2 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(127,0,0),0, 44, 59); //blue 4 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,0,127),200, 110, 121); //red 4 on - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(0,127,0),0, 16, 43); //blue 3 off - color, delay, start of segment, end of segment
  turnSegmentOn(strip.Color(50,50,0),0, 122, 134); //red 3 off - color, delay, start of segment, end of segment
  }

  fadeUpSeg(127,0,0,200,103,159); //red, green, blue, delay/speed, start of segment, end of segment
  fadeUpSeg(0,127,0,200,0,102); //red, green, blue, delay/speed, start of segment, end of segment
  fadeDownSeg(127,0,0,200,103,159); //red, green, blue, delay/speed, start of segment, end of segment
  fadeDownSeg(0,127,0,200,0,102); //red, green, blue, delay/speed, start of segment, end of segment
  fadeUpSeg(0,127,0,200,103,159); //red, green, blue, delay/speed, start of segment, end of segment
  fadeUpSeg(127,0,0,200,0,102); //red, green, blue, delay/speed, start of segment, end of segment
  fadeDownSeg(0,127,0,200,103,159); //red, green, blue, delay/speed, start of segment, end of segment
  fadeDownSeg(127,0,0,200,0,102); //red, green, blue, delay/speed, start of segment, end of segment
  fadeUpSeg(127,127,127,200,103,159); //red, green, blue, delay/speed, start of segment, end of segment
  fadeUpSeg(20,20,127,200,0,102); //red, green, blue, delay/speed, start of segment, end of segment
  fadeDownSeg(127,127,127,200,103,159); //red, green, blue, delay/speed, start of segment, end of segment
  fadeDownSeg(20,20,127,200,0,102); //red, green, blue, delay/speed, 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<repetitions; x++)
  {
    for(int i=0; i<strip.numPixels(); 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<lineNumber; 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(127,0,0));
             strip.setPixelColor(i+j+(3*lineNumber), strip.Color(0,127,0));
             strip.setPixelColor(i+j+(4*lineNumber), strip.Color(127,127,0));
             strip.setPixelColor(i+j+(5*lineNumber), strip.Color(0,127,127));
             strip.setPixelColor(i+j+(6*lineNumber), strip.Color(127,0,127));
             strip.setPixelColor(i+j+(7*lineNumber), strip.Color(0,0,127));
             strip.setPixelColor(i+j+(8*lineNumber), strip.Color(127,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<strip.numPixels(); 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(127);
         color2 = random(127);
         color3 = random(127);
         
         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 = 127 - WheelPos % 128;   //Red down
      g = WheelPos % 128;      // Green up
      b = 0;                  //blue off
      break;
    case 1:
      g = 127 - WheelPos % 128;  //green down
      b = WheelPos % 128;      //blue up
      r = 0;                  //red off
      break;
    case 2:
      b = 127 - WheelPos % 128;  //blue down
      r = WheelPos % 128;      //red up
      g = 0;                  //green off
      break;
  }
  return(strip.Color(r,g,b));
}
dom89
 
Posts: 29
Joined: Sun Nov 06, 2011 1:32 am

Re: LPD8806 Christmas Star Project

Postby wbp » Fri Dec 23, 2011 5:25 pm

I was truly inspired by this project, as you can see: http://www.youtube.com/watch?v=bDNqRPmNndo

This is a smaller version, 36" by 18", using 3 meters of the LED strip from Adafruit. This one is made using plywood, but I want to experiment with white acrylic. My eventual goal is to be able to hang this at the top of our redwood tree - it will be visible for blocks!
User avatar
wbp
 
Posts: 149
Joined: Mon Mar 07, 2011 12:18 pm


Next

Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit

Who is online

Users browsing this forum: No registered users and 6 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]