I got everything working. Here is the code...
#include <Wire.h>
char allModuleAddress = 104;
char module1Address = 111;
void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
Serial.println("Serial Initialized");
Wire.begin();
Serial.println("Wire Initialized as Master");
initModule(allModuleAddress);
Serial.println("InitModules Completed");
digitalWrite(13,HIGH);
randomSeed(analogRead(0));
}
boolean a[] = {true,true,true,true,true};
void loop()
{
int r = int(random(0,5));
Serial.println(r);
a[r] = !a[r];
if(a[r]) setLed(r,255);
else setLed (r,0);
delay(50);
}
// Initialise all outputs for pwm and global dimming, switch off sleep mode
void initModule(char address)
{
Wire.beginTransmission(address);
Wire.write(0x80);
Wire.write(0x01);
Wire.write(byte(0x00));
for (char i=0; i<16; i++) {
Wire.write(byte(0xFF));
}
Wire.write(byte(0xFF));
Wire.write(byte(0x00));
for (char i=0; i<4; i++) {
Wire.write(B10101010);
}
Wire.endTransmission();
}
// Set the brightness of one output
void setLed(char lednum, char brightness) {
Wire.beginTransmission(module1Address);
Wire.write(lednum+2);
Wire.write(brightness);
Wire.endTransmission();
}
The next part of my project that I am trying to figure out is how to interface it with this Darlington Transistor Array...http://www.ti.com/lit/ds/symlink/uln2803a.pdf Does anyone know how to do this. I got the array working by itself by attaching GND to GND, nothing to COM and then +5v to the inputs to connect output and ground. The problem is that the LED driver is a sink, so how do I control the darlington array which requires +volts. And what does the common do?
Thanks for the help
Patrick