Reads temperature input in mbed using i2c and prints it to computer terminal through serial

Dependencies:   mbed

Revision:
0:f003b8445395
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 08 00:21:58 2014 +0000
@@ -0,0 +1,32 @@
+//Author: Kuldip Maharjan
+//Email : kuldipmaharjan@gmail.com
+//Anyone can use this code if it helps in their projects or 
+//for learning programing in mbed besides for commercial purposes
+
+//Reads temperature input in mbed using i2c and prints it to computer terminal through serial 
+
+#include "mbed.h"
+
+I2C    i2c( p28, p27 );        // sda, scl
+AnalogIn temperature(p20);
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+    char v[2];
+    char cmd[2];
+    pc.baud(115200);
+    i2c.frequency(100000);
+    
+    cmd[0] = 0x0C;
+    cmd[1] = 0x0D;
+    pc.printf("kuldip");
+    while(1) {
+   
+        i2c.write( 0x34, cmd , 2 , true);
+        i2c.read( 0x34, v, 2 );
+
+        wait(1);
+        pc.printf("v[0] = %d.%d %%\t", v[0],v[1]);    
+     }
+}
\ No newline at end of file