Route Fix

Dependencies:   mbed Motor LSM9DS1_Library_cal PinDetect HC_SR04_Ultrasonic_Library

Revision:
5:85951362fd6d
Parent:
4:6546c17ac0a6
Child:
6:d25157f50f14
--- a/main.cpp	Wed Nov 21 19:33:33 2018 +0000
+++ b/main.cpp	Wed Nov 21 19:43:30 2018 +0000
@@ -68,7 +68,7 @@
     // Turn left 90 degrees:
     void turnLeft(float currt){
         stop();
-        while ((t.read()-currt) < 2) {
+        while ((t.read()-currt) < 1.4) {
             Lfront.speed(-1);
             Lback.speed(-1);
             Rfront.speed(1);
@@ -81,7 +81,7 @@
     // Turn right 90 degrees:
     void turnRight(float currt){
         stop();
-        while ((t.read()-currt) < 2) {
+        while ((t.read()-currt) < 1.4) {
             Lfront.speed(1);
             Lback.speed(1);
             Rfront.speed(-1);
@@ -99,16 +99,16 @@
 {
     if (distance < 150) {
     // PUT CODE HERE TO TRIGGER WHEN DISTANCE READS LESS THAN 15cm
-    // 1) Turn 90 degrees (hardcoded => 2 seconds).
-    // 2) Go forward 2 seconds.
-    // 3) Turn 90 degrees (hardcoded => 2 seconds).
+    // 1) Turn 90 degrees (hardcoded => 1.4 seconds).
+    // 2) Go forward 1.5 seconds.
+    // 3) Turn 90 degrees (hardcoded => 1.4 seconds).
     // 4) Continue forward until wall.
         // [Step 1]
         float currt = t.read();
         if (tr) {mctrl.turnRight(currt);} else {mctrl.turnLeft(currt);}
         // [Step 2]
         currt = t.read();
-        while ((t.read()-currt) < 2) {mctrl.fwd();}
+        while ((t.read()-currt) < 1.5) {mctrl.fwd();}
         // [Step 3]
         currt = t.read();
         if (tr) {mctrl.turnRight(currt);} else {mctrl.turnLeft(currt);}