So, I'm having a very weird problem. My current project needs 1200 individually controlled LEDs. To get this to work, I hooked 5 Arduinos up to a Raspberry Pi (via I2C) and 15 TLC5940 (using the library at Arduino Playground - HomePage) chips to each of those. The problem is that when I try to send a signal to the Arduino for it to turn on a channel, the python on the Raspberry Pi crashes, giving me an IOError number 5. I've used trial and error to determine that the Tlc.update(); function is what is causing the I2C error. The RPi and the LED driver aren't connected, so I can't figure out why this is happening. I think it may have something to do with timing, but I tried moving the Tlc.update(); function to void loop() from inside of the function run by i2c when it receives data, and that didn't work either. Is there something with the wire library that might be messed up by using the TLC chips?
Here is the arduino code:
#include "Tlc5940.h"
#include <Wire.h>
int address = 4;
int input = 0;
int pin = 12;
void setup(){
pinMode(pin, OUTPUT);
Wire.begin(address);
Wire.onReceive(recData);
}
void loop(){
delay(1);
}
void recData(int numBytes){
while(Wire.available()>0){
input = Wire.read();
Tlc.set(0, 4095);
Tlc.set(1, 4095);
Tlc.set(2, 4095);
Tlc.set(3, 4095);
Tlc.set(4, 4095);
Tlc.set(5, 4095);
Tlc.set(6, 4095);
Tlc.set(7, 4095);
Tlc.set(8, 4095);
Tlc.set(9, 4095);
Tlc.set(10, 4095);
Tlc.set(11, 4095);
Tlc.set(12, 4095);
Tlc.set(13, 4095);
Tlc.set(14, 4095);
Tlc.set(15, 4095);
Tlc.set(16, 4095);
Tlc.set(17, 4095);
Tlc.set(18, 4095);
Tlc.set(19, 4095);
Tlc.set(20, 4095);
Tlc.set(21, 4095);
Tlc.set(22, 4095);
Tlc.set(23, 4095);
Tlc.set(24, 4095);
Tlc.set(25, 4095);
Tlc.set(26, 4095);
Tlc.set(27, 4095);
Tlc.set(28, 4095);
Tlc.set(29, 4095);
Tlc.set(30, 4095);
Tlc.set(31, 4095);
Tlc.set(32, 4095);
Tlc.set(33, 4095);
Tlc.set(34, 4095);
Tlc.set(35, 4095);
Tlc.set(36, 4095);
Tlc.set(37, 4095);
Tlc.set(38, 4095);
Tlc.set(39, 4095);
Tlc.set(40, 4095);
Tlc.set(41, 4095);
Tlc.set(42, 4095);
Tlc.set(43, 4095);
Tlc.set(44, 4095);
Tlc.set(45, 4095);
Tlc.set(46, 4095);
Tlc.set(47, 4095);
Tlc.set(48, 4095);
Tlc.set(49, 4095);
Tlc.set(50, 4095);
Tlc.set(51, 4095);
Tlc.set(52, 4095);
Tlc.set(53, 4095);
Tlc.set(54, 4095);
Tlc.set(55, 4095);
Tlc.set(56, 4095);
Tlc.set(57, 4095);
Tlc.set(58, 4095);
Tlc.set(59, 4095);
Tlc.set(60, 4095);
Tlc.set(61, 4095);
Tlc.set(62, 4095);
Tlc.set(63, 4095);
Tlc.set(64, 4095);
Tlc.set(65, 4095);
Tlc.set(66, 4095);
Tlc.set(67, 4095);
Tlc.set(68, 4095);
Tlc.set(69, 4095);
Tlc.set(70, 4095);
Tlc.set(71, 4095);
Tlc.set(72, 4095);
Tlc.set(73, 4095);
Tlc.set(74, 4095);
Tlc.set(75, 4095);
Tlc.set(76, 4095);
Tlc.set(77, 4095);
Tlc.set(78, 4095);
Tlc.set(79, 4095);
Tlc.update();
}
}