TLC5940 Glittering Stars - Anyone done yet?

Hi there. I've got a plan to make a night light for my impending baby-boy using a TLC5940 and some white LED strips. I was just wondering if anyone has done something like this before? I've gotten one of the examples working fine but my coding skills aren't great. I can usually take different sections of code and get them to work how I like, but writing something new, especially using a library is a bit beyond me. I am after something that will make random strips dim from on-off-on. I've had a hunt around but can't find anything close to what I'm after, if someone could point me in the right direction it would be much appreciated.

Many Thanks Dean

How about 20 individual white LEDs? Take a 328P, build a minimal circuit with it, burn bootloader, connect 20 LEDs on each of it’s pins (except AREF and XTAL pins) and load up the following:

// Fade all IO by Osamu Iwasaki
// November 10, 2010

#include <MsTimer2.h>

#define OUT_MIN 0  // First pin
#define OUT_MAX 19  // Last pin (this includes the analog pins)

byte luminance[20];
byte lumi[20] = {};

void setup()
{
 int i;

 for(i = OUT_MIN; i <= OUT_MAX; i++){
   pinMode(i, OUTPUT);
   digitalWrite(i,LOW);
 }


 for(i = OUT_MIN; i <= OUT_MAX; i++){
   digitalWrite(i,HIGH);
   delay(150);
 }
 for(i = OUT_MIN; i <= OUT_MAX; i++){
   digitalWrite(i,LOW);
   //delay(50);
 }
 delay(1000);

 MsTimer2::set(1, int_pwm);
 MsTimer2::start();
}


void int_pwm() {

 static int f_wait[20];
 static int f_max_time[20];
 static int f_speed[20];
 static int f_ct[20];
 static long f_interval[20];

 static int ch;

 for(ch = OUT_MIN; ch <= OUT_MAX; ch++){
   if(f_wait[ch] == 0){
     f_wait[ch] = f_speed[ch] + 1;

     if( (f_ct[ch] < 255) )
       if(luminance[ch] != 255)
         luminance[ch] ++;

     if(f_ct[ch] == 255){
       if(f_max_time[ch] == 0)
         f_max_time[ch] = 0; // On Max Time
       else
         f_max_time[ch] --;
     }

     if( (f_ct[ch] > 255) && (f_ct[ch] < 511) && (f_max_time[ch] == 0))
       if(luminance[ch] != 0)
         luminance[ch] --;

     if(f_ct[ch] >= 511){
       if(f_interval[ch] == 0){
         f_interval[ch] = 10 * random(100); // fading seed
         f_speed[ch] = random(1); // fading speed
         f_ct[ch] = 0;
       }
       else
         f_interval[ch] --;
     }
     else
       f_ct[ch] ++;
   }
   f_wait[ch] --;
 }
}

void fading(){

 static byte counter = 0;
 static boolean prev_off[20];
 int i;

 for(i = OUT_MIN; i <= OUT_MAX; i++){
   if(lumi[i] == 0){
     if(prev_off[i] == HIGH){
       digitalWrite(i,LOW);
       prev_off[i] = LOW;
     }
   }
   else
     lumi[i] --;
 }

 counter --;

 if(counter == 0){
   for(i = OUT_MIN; i <= OUT_MAX; i++){
     if(luminance[i]){
       digitalWrite(i,HIGH);
       prev_off[i] = HIGH;
     }
     lumi[i] = luminance[i];
   }
 }
}


void loop(){
 fading();
}

Each LED will fade on/off on its own, different speed. The coder, Osamu, has a video here, with the LEDs connected to a Lilypad: http://www.flickr.com/photos/osamu_iwasaki/5200758133/

MsTimer2 is available from the playground: http://www.arduino.cc/playground/Main/MsTimer2

Wow, that looks amazing! Unfortunately I'm using 12v LED strips as this thing should be covering almost the entire ceiling. The only way I can see to do this with dimming capability would be the 5940. That code might give me some ideas though, thanks

I actually have a similar setup, however I used fiber optic strands to cover a ceiling, and they all came together in a corner where I have a small controller consisting of an AVR and a few LEDs doing exactly what you're seeing in that video. With the fiber optic strands mixed and scattered, it makes for a pretty cool twinkling effect. Or I can push a button and they all come on fill brightness, or turn off.

That sounds very much like what I'm after, are you driving them with a 5940 or directly from the arduino using the set-up above? I think I may be able to get away with using the cylon-type sketch that's available, then just randomising the position of each output. I'll need to change it from on-off instead of off-on though so they're all on at once. I've got some IR remote sensing code from another project I was working on so I'm hoping to use that to allow the mode to be set using a cheap mini remote, if the Duino has enough space for me to run both programs. I suppose I could go the route one of the guys on here has gone and run a slave Arduino with I2C, though that also may be beyond me :D

Thanks for your help

I made a custom Arduino clone and used all 20 pins much like that video. The next one I'm building will be using 5 high intensity RGB LEDs clustered together, wired through SPI ... that will only use 2 pins, which leaves the rest pretty much open to do whatever. It also means I can use something much smaller than a full blown 328P chip ... like the Tiny84 which has one SPI port, 14 pins, and 8K flash.

Hello,

if you use one TLC output for the stripe, please consider the maximum current of 120mA. Higher current might burn the TLC.

Regards Andreas

Hi Odysee Yeah, I came up against that limit, I've split the strips into shorter lengths @120mA each, depending on the total power dissipation this might work. the only thing I'm struggling with is coding for a random dimming effect