something
Dependencies: mbed Motor LSM9DS1_Library_cal PinDetect HC_SR04_Ultrasonic_Library
Diff: main.cpp
- Revision:
- 4:6546c17ac0a6
- Parent:
- 3:c07ea8bf242e
- Child:
- 5:85951362fd6d
--- a/main.cpp Wed Nov 21 19:30:56 2018 +0000 +++ b/main.cpp Wed Nov 21 19:33:33 2018 +0000 @@ -66,7 +66,7 @@ }; // Turn left 90 degrees: - void turnLeft(void){ + void turnLeft(float currt){ stop(); while ((t.read()-currt) < 2) { Lfront.speed(-1); @@ -79,7 +79,7 @@ }; // Turn right 90 degrees: - void turnRight(void){ + void turnRight(float currt){ stop(); while ((t.read()-currt) < 2) { Lfront.speed(1); @@ -105,13 +105,13 @@ // 4) Continue forward until wall. // [Step 1] float currt = t.read(); - if (tr) {mctrl.turnRight(currt)} else {mctrl.turnLeft(currt)} + 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) < 2) {mctrl.fwd();} // [Step 3] currt = t.read(); - if (tr) {mctrl.turnRight(currt)} else {mctrl.turnLeft(currt)} + if (tr) {mctrl.turnRight(currt);} else {mctrl.turnLeft(currt);} // [End] tr = !tr; }