So, i have tlc5940 running two rgb LEDs using three of its pwm outs. the anodes are switching at the same time in the code, but theyre a little faster when actually running it, so the colors blend together. I would upload a schematic, but all TLC5940 circuits are pretty much the same and i dont think its relevant any way.
With my code, i've tried putting the delay between the switch and it solves the blending problem, but the led duty cycle becomes so low the light is barely visible. ive tried every order of tlc.update, digitalWrite(6, high)/(7, low) or vice versa. nothing seems to change the issue but the delay. and the delay is not a good way to solve a problem. I'm very new at programming, so if you spot something out of order let me know.
i also took some pictures of the leds and it shows exactly whats going on down to the microsecond. Even with a 1 second delay, i could see the flicker of the red on the blue side and bleu on the red side.
this is a 1ms delay, you can see that red and blue mixed entirely:
this is a 5ms delay, there is still a bit of each color on the wrong side:
this is a 25ms delay. still, there is about 1ms of the wrong color on each side:
Here's the code:
#include <Tlc5940.h> // TLC5940 library
void setup()
{
Tlc.init(0); // initialize tlc5940
pinMode(6, OUTPUT); // set the anode pin of led one to output
pinMode(7, OUTPUT); // set the anode pin of led two to output
}
void loop()
{
int l = 16; // brightness factor 1 to 16
int r = 2; // tlc5940 pin 2 is for red
int g = 1; // tlc5940 pin 1 is for green
int b = 0; // tlc5940 pin 0 is for blue
Tlc.set(r, 255 * l); // set red 0 to 255 with brightness l
Tlc.set(g, 0 * l); // set green 0 to 255 with brightness l
Tlc.set(b, 0 * l); // set blue 0 to 255 with brightness l
delay(0); // delay, too small and the colors mix, too long and it gets blinky
digitalWrite(6, 1); // turn on led one
digitalWrite(7, 0); // turn off led two
Tlc.update(); // send updated information to the chip
Tlc.set(r, 0 * l); // set red 0 to 255 with brightness l
Tlc.set(g, 0 * l); // set green 0 to 255 with brightness l
Tlc.set(b, 255 * l); // set blue 0 to 255 with brightness l
delay(0); // delay, too small and the colors mix, too long and it gets blinky
digitalWrite(7, 1); // turn on led two
digitalWrite(6, 0); // turn off led one
Tlc.update(); // send updated information to the chip
}
so how do i correct for this, or is there another way i should be doing it?
I'm running this on the arduino mega 2560
I used the TLC5940 library
I used this for which pins go where: Google Code Archive - Long-term storage for Google Code Project Hosting.

