Writes and reads test values, displaying results on MBED LEDS

Dependencies:   mbed

Fork of I2C_HelloWorld_Mbed by mbed official

Files at this revision

API Documentation at this revision

Comitter:
oliverb
Date:
Fri Sep 16 09:08:25 2016 +0000
Parent:
0:f76c26307f9a
Commit message:
Tested with a PIC18F4520 acting as peripheral (slave), test displays 4 bits on LEDs, writes to PIC, waits 0.5s, reads value and displays then waits 0.5s.; Success=non flashing, fail=leds flash sent value-red value

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r f76c26307f9a -r 494c4f7f60db main.cpp
--- 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
diff -r f76c26307f9a -r 494c4f7f60db mbed.bld
--- a/mbed.bld	Thu Feb 14 17:24:48 2013 +0000
+++ b/mbed.bld	Fri Sep 16 09:08:25 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file