A sample code for training. Using LPCXpresso baseboard. This program let 16 LEDs blink via I2C (PCA9532).
Diff: main.cpp
- Revision:
- 0:f1c2852c4f57
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 16 04:58:22 2010 +0000 @@ -0,0 +1,35 @@ +/* + * mbed + LPCXpresso_baseboard demo code + * + * This code has been made for a training session. + * + * With this code, the mbed drives PCA9532 to control 16 LEDs. + * + * Copyright (c) 2010 NXP Semiconductors Japan + * Released under the MIT License: http://mbed.org/license/mit + * + * revision 1.0 16-Feb-2010 1st release + */ + +#include "mbed.h" + +I2C i2c( p28, p27 ); // sda, scl + +const int PCA9532_addr = 0xC0; // define the I2C Address + +const char data[2][5] = { + { 0x16, 0x00, 0x00, 0x00, 0x00 }, + { 0x16, 0x55, 0x55, 0x55, 0x55 } + }; + +int main() { + + char i = 0; + + while ( 1 ) + { + i2c.write( PCA9532_addr, data[ i++ & 0x1 ], 5 ); + wait( 0.5 ); + } +} +