Basic library to interface to a Microchip MCP23016 I/O expander using I2C
Testing code to blink 2 lights
#include "mbed.h" #include "MCP23016.h" MCP23016 PortExpand(D4, D5, 0); DigitalOut myled(LED1); int main() { PortExpand.pinMode(0, DIR_OUTPUT); PortExpand.pinMode(8, DIR_OUTPUT); while(1) { PortExpand.digitalWrite(0, 1); PortExpand.digitalWrite(8, 0); myled = 1; // LED is ON wait(1); // 200 ms PortExpand.digitalWrite(0, 0); PortExpand.digitalWrite(8, 1); myled = 0; // LED is OFF wait(1); // 1 sec } }