# How do I change the speed of fading with Tlc5940?

Hey, fresh meat here! I´ve just recently discovered Arduino and could use some help. I´m going to have 32 LEDs fading with seperate speeds in a organic way. I´ve been using example codes for some hours now, but the fading is way too rapid. I don´t know how to make a single LED to fade slow and smooth. Can you help me?

Below is the code I´m using right now, testing one LED. How do make the fading slower here?

``````#include "Tlc5940.h"

TLC_CHANNEL_TYPE channel;

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

void loop()
{
uint16_t duration = 3000 - (analogRead(0) * 2);
int maxValue = 4000;
uint32_t startMillis = millis();
uint32_t endMillis = startMillis + duration;
}

if (channel++ == NUM_TLCS * 16) {
channel = 0;
}
}
}
``````

I'd think that you could change the speed of fading by changing 'duration'. Currently it is set by an analog input on A0:

``````      uint16_t duration = 3000 - (analogRead(0) * 2);
``````

That will get you between 954 milliseconds (about a second) and 3000 milliseconds (three seconds).

You can make the decay time a constant:

``````      unsigned long duration = 10000; // Decay over 10 seconds
``````

Thank you johnwasser! Great...

Now, if I don´t want a total fade out, so that the LEDs never go down to zero, how do I make that happend?

kraken667: Now, if I don´t want a total fade out, so that the LEDs never go down to zero, how do I make that happend?

I'd guess that you'd set the start or end point of the fade to something other than zero.

Thanks again! Sorry for being such a neebie...