Hello!
I am a beginner at using Arduino. I want to lit and fade multiple LED's for which i am using Texas Instruments TLC5940 chip to expand PWM pins on Arduino.
link to TLC5940 datasheet:
I have written a simple code.
[#include <Tlc5940.h>
int sensUp = 4;
int sensDown = 7;
int outs[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int dt=220;
int onTime=1000;
void setup() {
//Initializing TLC chip
Tlc.init(0);
Serial.begin(9600);
pinMode(sensUp, INPUT);
pinMode(sensDown, INPUT);
}
void loop() {
int valUp=digitalRead(sensUp);
int valDown=digitalRead(sensDown);
if (valUp==1){
upSide();
}
else{};
if (valDown==1){
downSide();
}
else{};
}
void downSide(){
for ( int x = 5; x >=0 ; x--) {
for (int i = 0; i < 4096; i++) {
Tlc.set(outs[x], i);
delayMicroseconds(dt);
Tlc.update();
}
}
delay(onTime);
for ( int x =5; x>=0; x--) {
for (int i = 4095; i >= 0; i--) {
Tlc.set(outs[x], i);
delayMicroseconds(dt);
Tlc.update();
}
}
Tlc.clear();
}
void upSide(){
for ( int x = 0; x < 6 ; x++) {
for (int i = 0; i < 4096; i++) {
Tlc.set(outs[x], i);
delayMicroseconds(dt);
Tlc.update();
}
}
delay(onTime);
for ( int x =0; x<6; x++) {
for (int i = 4095; i >= 0; i--) {
Tlc.set(outs[x], i);
delayMicroseconds(dt);
Tlc.update();
}
}
Tlc.clear();
}
]
However, the problem i am facing is that the last LED in the loop doesn't turn off completely and is mildly lit whether the LED is lit in forward direction or vice-versa. I believe this a programming error since the problem is always with the last OUTPUT(led) of the TLC in the loop but suggestions are most welcome. I measured the voltage drop over the LED is in between 0.03Volts to 0.17Volts whereas on the other is 0V since they turn off completely.
I have attached a schematic diagram along this.
Any help is of great help to me. Thank you in advance.