Writes and reads test values, displaying results on MBED LEDS

Dependencies:   mbed

Fork of I2C_HelloWorld_Mbed by mbed official

main.cpp

Committer:
oliverb
Date:
2016-09-16
Revision:
1:494c4f7f60db
Parent:
0:f76c26307f9a

File content as of revision 1:494c4f7f60db:

#include "mbed.h"
 

I2C i2c(p28, p27);
BusOut myleds(LED1, LED2, LED3, LED4);


const int addr = 0xAA;

int main() {
  i2c.frequency(100000);
  while (1) {
  for(int aa=0;aa<16;aa++)
    {  
        myleds=aa;
        char cmd[2];
        cmd[0] = 0x00;
        cmd[1] = aa;
        i2c.write(addr, cmd, 2);
 
        wait(0.5);
 
        cmd[0] = 0x00;
        i2c.write(addr, cmd, 1,true);
        i2c.read(addr, cmd, 1);
        myleds=cmd[0];
        wait(0.5);
    }
  }
}