TLC5916 Lite Arduino Driver Library

GitHub repository can be found here: TLC5916_Lite

Appending to post, TLC5916 Driver Library.

I ported my code over to be an Arduino Library. I tested it with a Arduino Nano V3.0 and had to work out a few bugs, but overall really happy with the outcome. There are only a few methods that needs to be called, and I left the implementation open enough to create good building blocks.

First things first, I like to keep my code readable, so let’s use some define statements to represent the pin numbers.

#define SDI       5
#define CLK       4
#define LE        3
#define SDO       9
#define OE        8

Before the setup method, declare and initialize the TLC5916 object:

TLC5916_Lite tlc = TLC5916_Lite(SDI, CLK, OE, LE, SDO);

Now we have the object ‘tlc’ to communicate with the TLC5916.

There are two modes we can use, normal and special. Normal mode is where we shift bits in to the TLC5916 and turn on the respective LEDs. To switch to normal mode, you would use:

tlc.switchToNormalMode(); 

Then you can send a stream of bits to the TLC5916. If you have more than one chip, leave the last parameter false, which keeps the latch pin from pulsing. This will keep the data in the shift register to be shifted out to the next chip on the next call to ‘transmit’. The last byte of data to get sent will get the last parameter set to true, allowing the latch pin to pulse.

tlc.transmit(data_byte, 8, true);

Special mode can be used two ways, current gain and open circuit error detection. To get in to special mode, you would call:

tlc.switchToSpecialMode();

Current gain will allow small adjustments to how much current will flow through the LEDs.

tlc.writeConfiguration(brightness);

Open circuit detection will return a 1 for each bit operating normally. If I remove LED attached to the driver’s output pin 3, readErrorCodeStatus will return ‘0b1111 1011’

uint8_t reading = tlc.readErrorCodeStatus();

To see some examples of the library in action:

Thank for following along. If you liked this, check out my other software engineering related posts Please check out my recent posts to the right and thanks for following along!

Author:

Leave a Reply