You are viewing an older revision! See the latest version

PCA9635 I2C IO Expander

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.

#include "mbed.h"
#include "PCA9635.h"

DigitalOut enable(p26);
BusOut myleds(LED1, LED2, LED3, LED4);
PCA9635 my_driver(p28, p27, 0x02);

int main()
{
    enable = 0;
    
    short op = 1;
    for(char j = 0; j < 16; j++){
        myleds = j;
        my_driver.bus(op);
        wait(0.7);
        op = (op << 1);
    }

    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:

Import libraryPCA9635

PCA9635 16-bit I2C-bus LED driver

/media/uploads/d_worrall/_scaled_pca9635_schem.jpg

A pinout diagram is provided here:

/media/uploads/d_worrall/_scaled_pca9635_pinout.jpg

(To be revised soon as...)


All wikipages