Go Down

Topic: TLC59116F I2C LED driver (Read 3743 times) previous topic - next topic

RickP

Jan 18, 2011, 11:20 am Last Edit: Jan 18, 2011, 11:22 am by pannen Reason: 1
Hi,

I got some TLC59116F LED drivers as samples (http://focus.ti.com/docs/prod/folders/print/tlc59116f.html) and soldered them to SSOP adapters.

These are pretty cool because each module can drive 16 LEDs or 5 RGB LEDs with brightness control and you can drive up to 14 modules with just the two i2c pins.

I had some problems with getting this to work, because the outputs are disabled by default when it's powered on. So here's a little sketch for other who want to use the modules.

Without any pullups/pulldowns on the address pins a module has the address 96 - with the adress 104 you can talk to all modules at once, independent of their individual address. The outputs are open drains so you have to connect the kathodes of the leds to the driver.

Code: [Select]

#include <Wire.h>

char allModuleAddress = 104;
char module1Address = 96;

void setup()
{
 Wire.begin();
 initModule(allModuleAddress);
}

void loop()
{
 setLedBrightness(module1Address, 0, 5);
}

// Initialise all outputs for pwm and global dimming, switch off sleep mode
void initModule(char address)
{
 Wire.beginTransmission(address);
 Wire.send(0x80);
 Wire.send(0x01);
 for (char i=0; i<17; i++) {
   Wire.send(0x00);
 }
 for (char i=0; i<6; i++) {
   Wire.send(0xFF);
 }
 Wire.endTransmission();
}

// Set the global brightness to dim all lit leds
void setGlobalBrightness(char address, char brightness) {
 Wire.beginTransmission(address);
 Wire.send(0x12);
 Wire.send(brightness);
 Wire.endTransmission();
}

// Set the brightness of one output
void setLedBrightness(char address, char lednum, char brightness) {
 Wire.beginTransmission(address);
 Wire.send(0x02 + lednum);
 Wire.send(brightness);
 Wire.endTransmission();
}

// Set the brightness for 3 outputs at once (for rgb leds)
void setGroupBrightness(char address, char groupNum, char brightness_r, char brightness_g, char brightness_b) {
 Wire.beginTransmission(address);
 Wire.send(0xA2 + (3*groupNum));
 Wire.send(brightness_r);
 Wire.send(brightness_g);
 Wire.send(brightness_b);
 Wire.endTransmission();
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy