A sample code for training. Using LPCXpresso baseboard. This program let 16 LEDs blink via I2C (PCA9532).
main.cpp
00001 /* 00002 * mbed + LPCXpresso_baseboard demo code 00003 * 00004 * This code has been made for a training session. 00005 * 00006 * With this code, the mbed drives PCA9532 to control 16 LEDs. 00007 * 00008 * Copyright (c) 2010 NXP Semiconductors Japan 00009 * Released under the MIT License: http://mbed.org/license/mit 00010 * 00011 * revision 1.0 16-Feb-2010 1st release 00012 */ 00013 00014 #include "mbed.h" 00015 00016 I2C i2c( p28, p27 ); // sda, scl 00017 00018 const int PCA9532_addr = 0xC0; // define the I2C Address 00019 00020 const char data[2][5] = { 00021 { 0x16, 0x00, 0x00, 0x00, 0x00 }, 00022 { 0x16, 0x55, 0x55, 0x55, 0x55 } 00023 }; 00024 00025 int main() { 00026 00027 char i = 0; 00028 00029 while ( 1 ) 00030 { 00031 i2c.write( PCA9532_addr, data[ i++ & 0x1 ], 5 ); 00032 wait( 0.5 ); 00033 } 00034 } 00035
Generated on Wed Jul 13 2022 00:10:47 by 1.7.2