Arduino Uno and LPD 8806 LED strip solid color fade

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

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
TonyBleak
 
Posts: 1
Joined: Thu Aug 14, 2014 8:11 pm

Arduino Uno and LPD 8806 LED strip solid color fade

Post by TonyBleak »

OK, so I have been trying to figure this out and have searched the web and the forums to try and figure this out. What I want to do is set my strip (1 meter for now) to start at say White. I would like it to slowly fade to another color Blue maybe over time of about 5 minutes. Then fade to another color. Is this possible with this chipset?


User avatar
ZapBranigan
 
Posts: 16
Joined: Fri May 16, 2014 1:27 am

Re: Arduino Uno and LPD 8806 LED strip solid color fade

Post by ZapBranigan »

Tony,
I found this code on the forum a few months ago. It works well for what you are describing. I can't take credit for writing it, I've only modified it slightly to meet my needs. As you can see, the colors are defined in the setup portion. You can add as many colors as you like and fade them to your heart's content. This particular code is set up to use hardware SPI, so the data pin, clock pin are not defined, if you are using software SPI you will need to change that.
Enjoy.

Code: Select all

#include "LPD8806.h"
#include "SPI.h"


LPD8806 strip = LPD8806(160);


void setup() {
  // Pink
#define COLOR1_R 127
#define COLOR1_G 1
#define COLOR1_B 25
  // Aqua
#define COLOR2_R 0
#define COLOR2_G 93
#define COLOR2_B 66

#define top = 100; // maximum value of counter

  // Start up the LED strip
  strip.begin();

  // Update the strip, to start they are all 'off'
  strip.show();
}


void loop() {
  int r,g,b;
  uint16_t i, j;
  for (j=0; j < 40; j++) {
    r = map(j, 0, 40, COLOR1_R, COLOR2_R);
    g = map(j, 0, 40, COLOR1_G, COLOR2_G);
    b = map(j, 0, 40, COLOR1_B, COLOR2_B);

    for (i=0; i < 160; i++) { 
      strip.setPixelColor(i,(strip.Color(r,g,b) ));
    } 

    strip.show(); // write all the pixels out
    delay(100);
  }
  
  delay(3000); //pause after max values reached
  
  for (j=0; j < 40; j++) {
    r = map(j, 0, 40, COLOR2_R, COLOR1_R);
    g = map(j, 0, 40, COLOR2_G, COLOR1_G);
    b = map(j, 0, 40, COLOR2_B, COLOR1_B);

    for (i=0; i < 160; i++) { 
      strip.setPixelColor(i,(strip.Color(r,g,b) ));
    } 

    strip.show(); // write all the pixels out
    delay(100);
  }
  
  delay(3000); //pause after min values reached
  
}

Locked
Please be positive and constructive with your questions and comments.

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