Writes and reads test values, displaying results on MBED LEDS

Dependencies:   mbed

Fork of I2C_HelloWorld_Mbed by mbed official

Revision:
1:494c4f7f60db
Parent:
0:f76c26307f9a
--- a/main.cpp	Thu Feb 14 17:24:48 2013 +0000
+++ b/main.cpp	Fri Sep 16 09:08:25 2016 +0000
@@ -1,25 +1,30 @@
 #include "mbed.h"
  
-// Read temperature from LM75BD
 
 I2C i2c(p28, p27);
+BusOut myleds(LED1, LED2, LED3, LED4);
 
-const int addr = 0x90;
+
+const int addr = 0xAA;
 
 int main() {
-    char cmd[2];
-    while (1) {
-        cmd[0] = 0x01;
-        cmd[1] = 0x00;
+  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);
-        i2c.read(addr, cmd, 2);
- 
-        float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0);
-        printf("Temp = %.2f\n", tmp);
+        i2c.write(addr, cmd, 1,true);
+        i2c.read(addr, cmd, 1);
+        myleds=cmd[0];
+        wait(0.5);
     }
+  }
 }
\ No newline at end of file