This assembling guide is based on the yellow D.I.Y. kit p. 297 - 10.11 D.I.Y. Build a simple self-driving robot
Build an obstacle avoiding robot using a L298N motor controller module and an ultrasonic sensor.
* Please refer to the image below to identify what is inside your transparent screws bag. Note that you may find some more pieces than you need.
Build your robot and place the components on your breadboard as shown in the drawings.
You can start working on the assembling of the robot holding the bottom of the bigger plexi base (refer to the “TOP” label engraved on the plexi to be sure you hold it in the right way). Attach the two small plexi bars with 2x Ø 3mm x 12 mm screws and respective nuts. Fix the motors with 6x Ø 2mm x 6 mm screws as shown in the picture.
Turn the assembly upside up (check the “top” label) and attach the castor wheel with 2x Ø 2mm x 8 mm screws. Fix the Yellow board with the 4 plastic pegs provided in the yellow board box.
Fix the L298N motor controller module to the smaller plexi base using the 4x Ø 2mm x 10 mm screws (place the plastic spacers between it and the plexi base and fix it using the nuts as shown in the picture). To connect the breadboard, remove the protective film and attach the breadboard in the appropriate space.
Place the smaller plexi on the bigger one and fix the motors between them with the remaining 6x Ø 2mm x 6 mm screws. Fix the wheels to the appropriate gears of the motors, attaching them with the 2x Ø 2.2mm x 6.5 mm self-tapping screws.
You will now place the ultrasonic range finder and all the electronics components on your breadboard. Following the drawing you will connect all the components together in order to make your robot working!
Book Errata Corrige (CH 10, p. 297): Refer to this drawing to connect in the right way the ground pin of the ultrasonic range finder.
From the Github repository you can download the exercise sketch (30_10.11.ino) and open it in the IDE.
Code will give our circuit intelligence to become a self-driving robot. The bot will turn right when it detects an obstacle in front of it at a distance of 10 cm. Before it moves forward, it will keep turning until it detects no obstacles within 10 centimeters. You can adjust the speed and the distance in the code as you prefer.
After compiling and uploading the code, both motors will move forward. Now, try to place your hand in front of the ultrasonic range finder, both motors should stop for 0.5 seconds, then motor A will move forward but motor B will reverse. Both motors will move forward after 0.5 seconds if no obstacle has been detected.