Hi, I am experimentig multiplexing RGB leds with a TLC5940 but I have a strange problem. I have successfully already done this with a 74hc595 but I am not able to have a result with the TLC.
Basically I have 3 common anode rgb leds. I have connected the RGB pins to pin 0,1,2 of the TLC5940 and the 3 anodes of the led to analog 5,6,7
This is my test code
#include "Tlc5940.h"
void setup() {
Tlc.init();
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
void loop()
{
for (int i = 5; i <= 7; i++) {
/* Tlc.clear() sets all the grayscale values to zero, but does not send
them to the TLCs. To actually send the data, call Tlc.update() */
//Tlc.clear();
/* Tlc.set(channel (0-15), value (0-4095)) sets the grayscale value for
one channel (15 is OUT15 on the first TLC, if multiple TLCs are daisy-
chained, then channel = 16 would be OUT0 of the second TLC, etc.). */
if (i==5) {
Tlc.set(0, 0); //blue
Tlc.set(1, 0); //green
Tlc.set(2, 4095); //red
}
else if (i==6) {
Tlc.set(0, 0);
Tlc.set(1, 4095);
Tlc.set(2, 0);
}
else if (i==7){
Tlc.set(0, 4095);
Tlc.set(1, 0);
Tlc.set(2, 0);
}
Tlc.update();
digitalWrite(i, HIGH);
delay(3);
digitalWrite(i, LOW);
}
}
I have successuflly the 3 leds lighted at te same time for my eyes without flickering BUT the colors are wrong! I have tried also with just one led and still I get wrong color. I have discovered that if I use just one led switching off the others I have the expected color
if (i==5) {
Tlc.set(0, 0); //blue
Tlc.set(1, 0); //green
Tlc.set(2, 4095); //red
}
else if (i==6) {
Tlc.set(0, 0);
Tlc.set(1, 0);
Tlc.set(2, 0);
}
else if (i==7){
Tlc.set(0, 0);
Tlc.set(1, 0);
Tlc.set(2, 0);
}
With this I have a red one and two off. Also if I connect just one RGB led, with the first pasted code, I get it "purple".
I really don't understand.
Please help =(