www.keyestudio.com
8.7 Ultrasonic and Infrared Avoiding Obstacles
1) Description
In the previous sections, we have introduced ultrasonic obstacle avoiding car and infrared obstacle avoiding car.
To be more accurate, this lesson we combine both ultrasonic module and infrared obstacle detector sensors to
build an obstacle avoiding car.
2) Programming Thinking
When the distance between the car and front obstacle is less than or equal to 10cm, the robot car will
1
stop, passive buzzer beeps for 0.5 second, mini car will go backward for 0.2 second, and then turn left for 0.3
second.
When the distance between the car and front obstacle is greater than 10cm, use two infrared obstacle
2
detector modules on the car shield to detect whether there is obstacles on the front left or on the front right.
67