Hello,
I’m doing an audiovisual project, and I’m trying to use control 8 13W RGBW LEDs with PWM and two Adafruit PWM Shields (chip: https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf). I’m not using the shield to power the LEDs. Right now I’m having a problem writing to the PWM pins over I2C.
The LEDs work fine with the PWM pins on my Mega 2560 and analogWrite(), and I’ve been reading a lot about PWM and I2C, but some lack of understanding about PWM and/or I2C is probably to blame.
I want to be able to address the PWM pins 0-15 individually, sending them a value between 0 and 255 from Max/MSP. (I’ll be sending e.g. ‘65 0 0 0 0’, where 65 indicates the first LED ‘A’ and the rest are values b/t 0 and 255 and correspond to R, G, B, and W, and parsing this string in the Arduino.)
The way I understand it, the reason analogWrite(9, 255) works is because 255 is half 500, which is roughly the PWM frequency of the Mega’s pins. Reading the Adafruit library, it’s clear their code doesn’t have what I need. Their code involves calculating the actual cycle information.But I like that I can set the PWM frequency, so I use this in my code.
I checked the pinning of the PCA9685, and find that LED0 = Pin 6.
(Attachment 1)
So I think: Great, now I can tell the Arduino
-Tell the shield I’m talking to it
-Send a value 0-255 to the PWM pin 6
Here’s the code I think should work:
(Attachment 2)
Obviously, there’s I2C stuff missing. I need some sort of internal address. I also need to address the pull-up resistor (ssn’t that handled by begin/endTransmission?).
So I look at the registers and this scares me. ‘LED0 output and control byte 0, 1, 2, 3’ (?) :
(Attachment 3)
All I want to do is send the PWM value (what I think is most easily done from Max/MSP to Arduino as a single integer, and not a convoluted calculation as an actual parameter).
I’m frustrated and tired and I’ve been searching for so long, but nobody seems to have a similar issue. If I’m wrong, I’d appreciate if someone could link me to that and I’ll be on my merry way. In any case, I appreciate any and all help you guys will give me.
Thanks,
Keith


