PIDs and fun

Dependencies:   btbee m3pi_ng mbed FatFileSystemCpp

Revision:
5:3f29267b18e3
Parent:
4:0bcd7a924140
Child:
6:75a6f6b50188
--- a/main.cpp	Wed May 27 12:03:05 2015 +0000
+++ b/main.cpp	Wed May 27 12:24:22 2015 +0000
@@ -40,6 +40,7 @@
     m3pi.cls();
     
     Timer LapTimer;
+    Timer LoopTime;
     char Bat[] = {'V','o','l','t',' ','i','s'};
   m3pi.print(Bat,7);
   wait(0.75);
@@ -87,6 +88,7 @@
     int checkvar = 0;
     double Time1, Time2, Time3, Time4, Time5, TimeAve;
     bool IR = 1;
+    double timer;
     btbee.printf("\n");
     btbee.printf("Now starting \n");
     
@@ -95,6 +97,8 @@
     
     while (1) {
         
+    LoopTime.start();
+        
     IR = m3pi_IN [0];
         
     if(m3pi_IN [0] == 0 and IR == 0) {
@@ -216,7 +220,15 @@
         btbee.printf("Average time per lap: %f ", TimeAve);
         exit(1);
         }
-
+        
+    timer = LoopTime.read();
+    btbee.printf("%f", timer);
+    btbee.printf("\n");
+    if(timer < 0.005) {
+        wait(0.005 - timer);
+        }
+    timer = 0;
+    LoopTime.reset();
 
     }