PCA9635
.
This is a 16-bit I2C-bus LED driver and as a result is a useful bus expander. Only 2 bus lines are needed to interface the mbed with the PCA9635, including an additional enable pin. The advantage of using I2C it that many PCA9635 chips can be connected to the same bus lines in parallel and using an addressing system can be selected individually.
Pinout
Example Code
N.B.
Always call init() on start up to clear the registers before operations begin.
#include "mbed.h" #include "PCA9635.h" DigitalOut enable(p26); PCA9635 my_driver(p28, p27); int main() { //REMEMBER enable enable = 0; //N.B. you MUST declare init(int address), before calling any PCA9635 functions //turns each pin on and then off my_driver.init(0x02); short illuminate = 1; for(char j = 0; j < 16; j++){ my_driver.bus(illuminate); wait(0.7); op = (op << 1); //illuminate LEDs with port bit high } //ramp brightness up three times faster than down, repeatedly while(1) { for(char valueUp=0; valueUp<0xFF; (valueUp = valueUp + 3)) { my_driver.brightness(ALL, valueUp); } for(char valueD=0; valueD<0xFF; valueD++) { my_driver.brightness(ALL, (0xFF - valueD)); wait(0.007); } } }
Library
The libraries for connecting the mbed can be found here
Please log in to post comments.