Leo Bach / Mbed 2 deprecated Prosjekt_2

Dependencies:   SRF02 SRF05 mbed

Fork of Prosjekt_2 by HIOF Programmering

Revision:
6:5fee13e621e0
Parent:
5:7209741a08bc
Child:
7:112b745b2b9e
--- a/main.cpp	Thu Mar 17 12:28:53 2016 +0000
+++ b/main.cpp	Thu Mar 17 13:53:45 2016 +0000
@@ -1,7 +1,6 @@
 #include "mbed.h"
 #include "SRF05.h"
 
-/* Oppretter kommunikasjon til datamaskin & bluetooth */
 Serial pc(USBTX, USBRX);
 Serial bt(p13, p14);
 
@@ -54,8 +53,8 @@
                 break;
             }
             default:
-                pc.printf("\nERROR: Uknown value of Tri\n");
-                bt.printf("\nERROR: Uknown value of Tri\n");
+                pc.printf("\nERROR: Invalid value\n");
+                bt.printf("\nERROR: Invalid value\n");
         }
     }
 }
@@ -100,6 +99,10 @@
             wait_ms (50);
         } else if(a == 'n')
             break;
+        else {
+            pc.printf("\nInvalid input\n");
+            bt.printf("\nInvalid input\n");
+        }
     }
     for(int x = 1; x <= 10; x++)
         bar[x] = 0;
@@ -134,14 +137,13 @@
     while(1) {
         t.start();
         start = srf.read();
-        while (t.read() < 0.10) {
-            if (srf.read() < 10)
-                break;
-        }
+        while (t.read() < 0.25 && srf.read() < 10) {}
         t.stop();
         stopp = srf.read();
-        if (0.05 < (start-stopp)/(10) && start < 350 && stopp < 350)
-            pc.printf("\nHastighet er: %0.2f km/t", (start-stopp)*3.6/(10));
+        if (0.05 < (start-stopp)/(25) && start < 350 && stopp < 350) {
+            pc.printf("\nVelocity is = %0.2f km/t", (start-stopp)*3.6/25);
+            bt.printf("\nVelocity is = %0.2f km/t", (start-stopp)*3.6/25);
+        }
         t.reset();
         if(input() == 'n') break;
     }