4.4Exp4: Avoiding Obstacles

Share for us

Game Instruction

The game is to make Rollman avoid an obstacle. By comparing the distance set in the code and that detected of the ultrasonic module away from the obstacle, the Rollman can tell what to do – stop and turn right when an obstacle is detected. Now let us check how to make it happen. 

Experimental steps

  1. Connect the two motors to ports M1 and M2. Similarly, M1 is connected to the left motor and M2 the right one from the perspective of the robot’s front. Plug the power source into P1 for supply. Connect the ultrasonic to port S2 of the mainboard.
  • Upload Exp4_Rollman_avoidobstacle.ino under Rollman\Arduino Code\Exp4_Rollman_avoidobstacle to the Rollman.
  • Remove the USB cable, switch on the power. Rollman will read the distance detected by the ultrasonic module and compare it with the distance set in the program. If the detected distance is less than the set value, Rollman will go backward and turn right to bypass it. Otherwise, it will go forward. Then the obstacle can be avoided.

Extension

You can try to design and draw a maze and use cartons as obstacles for Rollman to run on the maze when avoiding obstacles. You can modify the distance in the program to different values to adapt. Have fun!