Lu-Hsuan Chen
/
autocar_obstacle_mbed
autocar with cliff and obstacle avoidance feature
Diff: autocar/autocar.cpp
- Revision:
- 1:c7d5b9662b4f
- Parent:
- 0:b9d5ff825f0f
--- a/autocar/autocar.cpp Thu Jul 19 05:17:01 2018 +0000 +++ b/autocar/autocar.cpp Thu Jul 19 05:41:17 2018 +0000 @@ -236,6 +236,22 @@ } } +void obstacle(bool hasCliff, bool hasObstacle) +{ + if(hasCliff || hasObstacle) + { + backward(); + wait_ms(300); + stop(); + wait_ms(200); + turnRight(); + wait_ms(200); + } + + forward(); + wait_ms(200); +} + void init() { DriveSingleMotor(MOTOR_M1, PWR_STOP, DIR_FORWARD);