LED BAR INDICATOR TLC5940

LED bar indicator TLC5940

The code can be downloaded at :

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/LED_BAR_INDICATOR_TLC5940.zip

#include <Tlc5940.h>

void tlc_progress(word value, word prefix)
{
byte out_num = value / 4096;
word out_brg = value % 4096;

for (byte out=0; out<16; out++)
{
if (out < out_num)
{
Tlc.set(out, prefix);
}

else if (out == out_num)
{
Tlc.set(out, out_brg);
}

else
{
Tlc.set(out, 0);
}
}
}

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

void loop()
{
int value = analogRead(0);
value = map(value, 0, 1023, 0, 65535);
tlc_progress(value, 4095);
Tlc.update();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s