one lap kind of works

Dependencies:   FatFileSystem MSCFileSystem btbee m3pi_ng mbed

Fork of Robot by IESS

Files at this revision

API Documentation at this revision

Comitter:
nbtavis
Date:
Fri May 22 13:26:21 2015 +0000
Parent:
2:80a1ed62c307
Child:
4:acd0f86ed832
Commit message:
Robot code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu May 21 14:38:47 2015 +0000
+++ b/main.cpp	Fri May 22 13:26:21 2015 +0000
@@ -2,6 +2,7 @@
 #include "btbee.h"
 #include "m3pi_ng.h"
 m3pi robot;
+DigitalIn m3pi_IN[]= {(p12),(p21)}; // IR sensor and Knopf
 Timer timer;
 Timer time_wait;
 #define MAX 0.95
@@ -39,6 +40,8 @@
    
 
    time_wait.start(); 
+   
+   
    while(y)
    {time_wait.reset();
    //Get raw sensor values
@@ -51,6 +54,9 @@
    if (robot.battery() < 2.4)
     {timer.stop();
         break;}
+        
+    else if (m3pi_IN [0] == 0)
+    {break;}
    
     else if( x[0] > 300 && x[2]>300 && x[4]>300)
             { if (lap == 0)
@@ -134,7 +140,7 @@
    robot.left_motor(left);
    robot.right_motor(right);
    
-   wait(.005-time_wait.read());
+   wait((5-time_wait.read_ms())/1000);
    }