Writes and reads test values, displaying results on MBED LEDS

Dependencies:   mbed

Fork of I2C_HelloWorld_Mbed by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  
00003 
00004 I2C i2c(p28, p27);
00005 BusOut myleds(LED1, LED2, LED3, LED4);
00006 
00007 
00008 const int addr = 0xAA;
00009 
00010 int main() {
00011   i2c.frequency(100000);
00012   while (1) {
00013   for(int aa=0;aa<16;aa++)
00014     {  
00015         myleds=aa;
00016         char cmd[2];
00017         cmd[0] = 0x00;
00018         cmd[1] = aa;
00019         i2c.write(addr, cmd, 2);
00020  
00021         wait(0.5);
00022  
00023         cmd[0] = 0x00;
00024         i2c.write(addr, cmd, 1,true);
00025         i2c.read(addr, cmd, 1);
00026         myleds=cmd[0];
00027         wait(0.5);
00028     }
00029   }
00030 }