TLC59116F I2C LED driver

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.

#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();
}