Code Explanation Avoidance.ino

Share for us

We have learnt a lot on servo and basic control for the RollFlash and how it moves. Thus, it would be quite easy to control it for obstacle avoiding. The program can judge whether there is an obstacle in front of the RollFlash by reading data from ultrasonic module on it, and further control the robot to avoid the obstacle by corresponding programs.

The program above is to read data from the ultrasonic. By calling this program to read the data, we can know how far the obstacle is ahead. Then write the code that if there is an obstacle 10cm away in the front, control the RollFlash to move back to 15cm from the obstacle, then turn left or right to avoid it, and continue to move. Thus, the RollFlash can realize obstacle avoiding function.

The program above is to read data from the ultrasonic. By calling this program to read the data, we can know how far the obstacle is ahead. Then write the code that if there is an obstacle 10cm away in the front, control the RollFlash to move back to 15cm from the obstacle, then turn left or right to avoid it, and continue to move. Thus, the RollFlash can realize obstacle avoiding function.