Route Fix
Dependencies: mbed Motor LSM9DS1_Library_cal PinDetect HC_SR04_Ultrasonic_Library
Diff: main.cpp
- Revision:
- 7:5667ce16d526
- Parent:
- 6:d25157f50f14
- Child:
- 8:2d0fc244cc65
--- a/main.cpp Wed Nov 21 20:32:01 2018 +0000 +++ b/main.cpp Sun Nov 25 20:09:50 2018 +0000 @@ -35,12 +35,12 @@ Lback.speed(0); Rfront.speed(0); Rback.speed(0); - wait(0.02); + wait(0.55); }; // Go forward at constant speed: void fwd(void){ - stop(); + //stop(); Lfront.speed(1); Lback.speed(1); @@ -62,27 +62,27 @@ // Turn left 90 degrees: void turnLeft(float currt){ stop(); - while ((t.read()-currt) < 1.4) { + while ((t.read()-currt) < 1.30) { Lfront.speed(-1); Lback.speed(-1); Rfront.speed(1); Rback.speed(1); } stop(); - wait(0.02); + //wait(0.02); }; // Turn right 90 degrees: void turnRight(float currt){ stop(); - while ((t.read()-currt) < 1.4) { + while ((t.read()-currt) < 1.30) { Lfront.speed(1); Lback.speed(1); Rfront.speed(-1); Rback.speed(-1); } stop(); - wait(0.02); + //wait(0.02); }; } mctrl; @@ -102,7 +102,7 @@ if (tr) {mctrl.turnRight(currt);} else {mctrl.turnLeft(currt);} // [Step 2] currt = t.read(); - while ((t.read()-currt) < 1.5) {mctrl.fwd();} + while ((t.read()-currt) < .5) {mctrl.fwd();} // [Step 3] currt = t.read(); if (tr) {mctrl.turnRight(currt);} else {mctrl.turnLeft(currt);} @@ -133,7 +133,6 @@ // Initialize the Timer: t.start(); - pc.printf("sw is : %d", sw); while(!sw) { usensor.checkDistance();