Hi! I'm trying really hard to control individual LEDS all hooked up to a TLC 5940. I would like
-
to use a push button to turn an LED on and off (I can of course do this with the regular sketch using this solution (from the book), but I'd like to access the individual LED controls within the TLC 5940:
if (val == HIGH) {
digitalWrite(LED, 1);
}else{
digitalWrite(LED, LOW); -
keep the line of 16 LEDs running with the one (or more LEDs) on - each controlled by its own push button.
Here's my sketch so far, and thanks so much for the help - I've taken out the parts that don't work, but the line of LEDs works the way I'd like it to, and I've added a dial potentiometer to control the speed of the LEDs.
#include "Tlc5940.h"
#define ANALOG_PIN1 1
#define BUTTON 2
#define LED 7
int val = 0; //ME
int val2 = 0; //me
void setup()
{
Tlc.init();
pinMode(BUTTON, INPUT);
pinMode(LED, OUTPUT);
}
void loop()
{
for (int channel = 0; channel < NUM_TLCS * 16; channel += 1)
{
int direction = 1;
Tlc.clear();
Tlc.set(channel, 25); //MR- I changed the (channel, 0) value from 1000 to 0 to stop the gradual fade from light to light.
Tlc.update();
delay(analogRead(ANALOG_PIN1)); //me
// val = digitalRead(BUTTON);
val2 = digitalRead(BUTTON);
// if (val == HIGH) {
// digitalWrite(LED, 1);
// }else{
// digitalWrite(LED, LOW);
// }
// if (val2 == HIGH) { //me
// digitalWrite(channel = 4, 25); //me
// } else { //me
// digitalWrite(channel = 4, 0); //me
// }
}
}