TLC5940 Fade, then hold LED

I've got 2 TLC5940's daisy chained and working fine. I can fade various LEDs and they work Ok, as long as they're constantly fading.

However, I'd like to be able to set it so an LED fades, then holds at the max brightness for a while (30seconds - 5 minutes.... making a clock). Every 30 seconds or so a Timed Action runs and checks to see what the time is (based off of a RTC module). When the time is different, I'd like it to slowly fade to the next time, like a 5 second fade. For some reason, I can't wrap my head around the logic.

Just keep updating the channel with the same value.

there is a command called tlcSet(channel, value); I believe those are the params but you should just google tlcSet first.

It sets the channel at a value.

Since tlcaddFade has a start and a finish, not a start middle and finish. You can fade to the where you want to go, and then set at where you ended, hold and then add the fade that goes from the highest to the lowest using the addFade again.

I am trying to do the exact same thing as barrysfarm.
I am using a TLC5940 to fade LEDs to a certain value, then hold that value for about 5 minutes then fade back down. -when the time changes another set of LEDs will fade in, hold their value, then back down, so on and so forth.

Here is a bit of the code that I am trying to use, but can’t make work correctly. I have played with this and I can get the LEDs to fade or I can get the LEDs to hold their value, but I can’t get them to do both sequentially.

I would appreciate any help I can get.

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include “RTClib.h”
#include “Tlc5940.h”
#include “tlc_fades.h”

RTC_DS1307 RTC;

unsigned long time;

void setup () {
Serial.begin(9600);
Wire.begin();
RTC.begin();
Tlc.init();

//if (! RTC.isrunning())
{
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(DATE, TIME));
}
}

void loop () {
DateTime now = RTC.now();

time = ((now.minute() * 60) + now.second());

if(now.hour() == 0){ //0th hour
if((3450 <= time && time < 3549)||(0 <= time && time < 150)){
Serial.println(“TWELVE O’CLOCK”);
int direction = 1; //Is this necessary?
for (int channel = 0; channel < NUM_TLCS * 16; channel += direction) { //Is this necessary?
if (channel == 0) { //Is this necessary?
direction = 1; //Is this necessary?
} else { //Is this necessary?
tlc_addFade(1, 0, 4000, millis(), millis()+4000); //Fade from a value of 0 to 4000 in 4 seconds
tlc_updateFades(); //
tlc_removeFades(1); //Level off
Tlc.set(1, 4000); //Hold luminosity constant until time changes
while(Tlc.update()); //
}
}
}
if(150 <= time && time < 450){
Serial.println(“FIVE PAST TWELVE”);
//Repeat fade routine…
}

cody, it seems tgat most of your questions are related to the fading operation and not the logic of the clock to fade issue. I think if you were to study the tlc5940 fades example as well as the methods in the library, it would easily answer your questions. I've gone ahead and found you the library for the methods. http://alex.kathack.com/codes/tlc5940arduino/html_r014/

Dont forget to look at its fade example

I appreciate the help, funkyguy.

Here is what I have come up with, a modification of the Fades example: Both the 'then' and 'else' portions of this seem to work when ran independently, but when placed together in this conditional statement, the LED stays lit indefinitely at the Tlc.set(value).

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

int count = 0;

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

void loop()
{
  if(count == 0){
    uint16_t duration = 4000;
    int maxValue = 4000;
    uint32_t startMillis = millis() + 50;
    uint32_t endMillis = startMillis + duration;
    tlc_addFade(1, 0, maxValue, startMillis, endMillis); //Fade to 4000 in 4 seconds
    tlc_updateFades();
    count = count + 1;
  }
  else{
    Tlc.set(1,4000);                                     //Set brightness to 4000 indefinitely
    Tlc.update();
  }
}

try moving your update statements out of the if/else. Maybe that'll do it.