A sample code for training. Using LPCXpresso baseboard. This program let 16 LEDs blink via I2C (PCA9532).

Dependencies:   mbed

Committer:
okano
Date:
Tue Feb 16 04:58:22 2010 +0000
Revision:
0:f1c2852c4f57

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:f1c2852c4f57 1 /*
okano 0:f1c2852c4f57 2 * mbed + LPCXpresso_baseboard demo code
okano 0:f1c2852c4f57 3 *
okano 0:f1c2852c4f57 4 * This code has been made for a training session.
okano 0:f1c2852c4f57 5 *
okano 0:f1c2852c4f57 6 * With this code, the mbed drives PCA9532 to control 16 LEDs.
okano 0:f1c2852c4f57 7 *
okano 0:f1c2852c4f57 8 * Copyright (c) 2010 NXP Semiconductors Japan
okano 0:f1c2852c4f57 9 * Released under the MIT License: http://mbed.org/license/mit
okano 0:f1c2852c4f57 10 *
okano 0:f1c2852c4f57 11 * revision 1.0 16-Feb-2010 1st release
okano 0:f1c2852c4f57 12 */
okano 0:f1c2852c4f57 13
okano 0:f1c2852c4f57 14 #include "mbed.h"
okano 0:f1c2852c4f57 15
okano 0:f1c2852c4f57 16 I2C i2c( p28, p27 ); // sda, scl
okano 0:f1c2852c4f57 17
okano 0:f1c2852c4f57 18 const int PCA9532_addr = 0xC0; // define the I2C Address
okano 0:f1c2852c4f57 19
okano 0:f1c2852c4f57 20 const char data[2][5] = {
okano 0:f1c2852c4f57 21 { 0x16, 0x00, 0x00, 0x00, 0x00 },
okano 0:f1c2852c4f57 22 { 0x16, 0x55, 0x55, 0x55, 0x55 }
okano 0:f1c2852c4f57 23 };
okano 0:f1c2852c4f57 24
okano 0:f1c2852c4f57 25 int main() {
okano 0:f1c2852c4f57 26
okano 0:f1c2852c4f57 27 char i = 0;
okano 0:f1c2852c4f57 28
okano 0:f1c2852c4f57 29 while ( 1 )
okano 0:f1c2852c4f57 30 {
okano 0:f1c2852c4f57 31 i2c.write( PCA9532_addr, data[ i++ & 0x1 ], 5 );
okano 0:f1c2852c4f57 32 wait( 0.5 );
okano 0:f1c2852c4f57 33 }
okano 0:f1c2852c4f57 34 }
okano 0:f1c2852c4f57 35