Die Steine / Mbed 2 deprecated Nucleo_Aufgabe3Stern

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Danyal
Date:
Wed Jan 16 12:34:02 2019 +0000
Parent:
1:b04a2ad0ab36
Commit message:
steine

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jan 16 11:59:20 2019 +0000
+++ b/main.cpp	Wed Jan 16 12:34:02 2019 +0000
@@ -10,14 +10,17 @@
     char cmd[4];
     cmd[0]=0x11;
     cmd[1]=0x00;
+ 
+    int8_t temp1 = 0;   
+    int8_t temp2 = 0;
     
     while(1){
         cmd[0]=0x11;
         i2c.write(addr8bit, cmd, 1);
         i2c.read(addr8bit, cmd, 2);
         
-        
-        pc.printf("Temperatur: %d.\n", (int8_t) cmd[0]);
+        temp1 = (int8_t) cmd[0];
+        //pc.printf("Temperatur: %d.\n", cmd[0]);
         
         wait(0.5);
  
@@ -26,7 +29,17 @@
         i2c.read(addr8bit, cmd, 2);
         
         
-        pc.printf("Temperatur: %d.\n", (int8_t) cmd[0]);
+        if (cmd[0] == 0x40){
+            temp2 = 25;} 
+        else if (cmd[0] == 0x80) {
+            temp2 = 50;}
+        else if (cmd[0] == 0xb0) {
+             temp2 = 75;}
+        else {
+             temp2 = 00;}
+                
+        
+        pc.printf("Temperatur: %d.%d Grad\n", temp1, temp2);
  
         //int8_t tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0);
         //printf("Temp = %.2f\n", tmp);