Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "MCP23017.h" 00003 00004 DigitalOut myled1(LED1); 00005 DigitalOut myled2(LED2); 00006 00007 Serial pc(USBTX, USBRX); 00008 I2C i2c(p9, p10); 00009 00010 MCP23017 mcp23017 = MCP23017(i2c, 0x40); 00011 00012 int main() { 00013 00014 pc.printf("Hello World\n"); 00015 00016 // I2C init 00017 i2c.frequency(100000); 00018 00019 // Port A is databus - Output 00020 mcp23017.direction(PORT_A, PORT_DIR_OUT); 00021 // Port B is controlbus - Output 00022 mcp23017.direction(PORT_B, PORT_DIR_OUT); 00023 00024 myled2 = 1; 00025 pc.printf("MPC Init done\n"); 00026 00027 while(1) { 00028 myled1 = 1; 00029 mcp23017.write(PORT_A, 0xFF); 00030 mcp23017.write(PORT_B, 0xFF); 00031 wait(0.2); 00032 00033 myled1 = 0; 00034 mcp23017.write(PORT_A, 0x00); 00035 mcp23017.write(PORT_B, 0x00); 00036 wait(0.2); 00037 pc.printf("*"); 00038 } 00039 }
Generated on Wed Jul 13 2022 14:35:21 by
1.7.2
MCP2317 I2C 16 bit I/O expander