Go Down

Topic: TLC5940, cant fade more than 12 pins at the same time? (Read 976 times) previous topic - next topic

tessomc

Guys... im a bit lost here...

Im building a small led tree, using TLC5940 and RGB leds

im trying to fade 16 rgb leds at the same time, at the beginning only the blue pins...

when i ran the fade example. it all works ok. But then i try to fade all the blue pins (or, red, green, dosent matter wich), i just only fade the first 12 ones...

here is my code:

Code: [Select]

#include "Tlc5940.h"
#include "tlc_fades.h"

int pinR[16] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
int pinG[16] = {1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46};
int pinB[16] = {2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47};

int i = 0;

void setup()
{
  Tlc.init();
}

void loop(){


    if (!tlc_isFading(pinB[0])) {
        uint16_t duration = 3000;
        int maxValue = 4095;
        uint32_t startMillis = millis() + 50;
        uint32_t endMillis = startMillis + duration;
       
        for(int a =0; a < 16; a++){
          tlc_addFade(pinB[a], 0, maxValue, startMillis, endMillis);
          tlc_addFade(pinB[a], maxValue, 0, endMillis, endMillis + duration);
        }
    }
       
  tlc_updateFades();

}


im using the library Tlc5940_r014.zip    Latest Stable Build as of May 7th, 2009

thanks for the help!

johnwasser

In "tlc_fades.h" you will find:
Code: [Select]

#ifndef TLC_FADE_BUFFER_LENGTH
/** The default fade buffer length (24).  Uses 24*13 = 312 bytes of ram. */
#define TLC_FADE_BUFFER_LENGTH    24
#endif


You should put:
Code: [Select]

#define TLC_FADE_BUFFER_LENGTH    32

in your code above "#include "tlc_fades.h"" if you want to have an up-fade and down-fade for 16 channels at once.  For all 48 LEDs you should change it to 96.  Of course that will use 1248 bytes of SRAM which is more than half the SRAM of an Arduino UNO.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

tessomc

Thanks john!! works great!

now im with another problem hehe... how the heck can i realize that the fade stoped (like 1 fade) then make it do another thing, like stay still, or do another fade in another pins?

the only problem is that i cant figure out how to stop it at the end.

Any ideias?


The big picture, im creating a led tree, show it should fade all the time, very smoothly and in a long period of time, and stay switching colors.

If only i knew how to stop the fade at the end of it.

Go Up