Buy from OSOYOO Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

In this project, we use two IR tracking sensors to design a simple line tracking Robot car. A Line tracking Robot, as the name suggests, is an auto-driving vehicle  which follows a black track line printed in white  ground. Tracking sensors in the robot keeps checking if the current car location is out of the track. If yes, then the car will make a negative movement to draw the robot car back to track.

OSOYOO Building Block Robot Car Lesson2: Line Tracking Car

Please prepare the following parts to complete this project
NOTE:
1.the color of the building block is subject to the actual product, which does not affect the use.
2. ALL OSOYOO PRODUCTS FOR ARDUINO ARE THIRD PARTY BOARD WHICH IS FULLY COMPATIBLE WITH ARDUINO


Before you build the robot with blocks, please install OSOYOO basic board for Arduino under OSOYOO Magic I/O shield as following (Attention please : the pins of I/O shield is aligned with the port of basic the board firstly, then press the shield tightly on the board.

Please follow the building steps to build this robot car, If you want to get clear PDF building steps, please download from https://osoyoo.com/picture/Building_Robot_Car/lesson2/LESSON2.pdf
Note: If you have built the robot car for lesson1, please skip to the step35 in this PDF.










Please connect motors and 9V battery case as lesson1. Then connect left tracking sensor to D2 of the Magic I/O shield, right to D13 port with 3-pin PNP cables as below (Attention please: there are six jumper caps on ENA/ENB/IN1/IN2/IN3/IN4):

Note: In this kit, we use mblock as programming tool, if you want to learn more about mblock, please visit preparation before class 1: https://osoyoo.com/2021/12/01/preparation-before-class-1

Step 1) Download mBlock PC version from https://mblock.makeblock.com/en-us/download/, select the download file as per your computer OS type (Please don’t use the browser version):

Step 2) Download OSOYOO_UNO.mext device file from https://osoyoo.com/driver/mblock/osoyoo_uno.mext

Step 3) Run the mBlock PC software by double-click the lovely Panda icon. You will seem Block UI as the following picture. Please delete the default device CyberPi by click the cross in the red circle.

Step 4) Drag and Drop osoyoo_uno_mext file(downloaded in Step 2) to mBlock software as following:

Now you will see a new device firmware in mBlock, see following picture:

Now, mBlock software and OSOYOO_UNO device firmware have been successfully installed in our PC!

Now we will show you how to use blocks to turn the above idea into reality.

Step 5: Click Events,   add when Arduino UNO starts up block to the top:

Step 6: Click Control, then drag and drop Forever block to programming area as the following:

Step 7: Click Control,   add an if else block inside forever loop, then add another if else block inside the else area of the first if else block:

Step 8: Click Sensor, add 2 pcs of IR Tracking Sensor Pin 2 blocks inside if condition area, change 2nd Pin from 2 to 13 as following:

Step 9: Click Action category, add 3 pcs  Backward Left Speed 100 Right Speed 100 block inside if else   blocks, change first Right Speed from 100 to 0, change 2nd Left Speed from 100 to 0 :

Now we have completed the block programming.  The final blocks look like the following:

Step 10) Upload the program to OSOYOO basic board

1) Please connect your OSOYOO basic board to your PC with USB cable firstly. Then click the Connect button in the bottom of the mBlock software, you will see a USB window pop up,
2) select Show all connectable device check box, then a device drop-down menu will show up,
3) select your  port from device drop-down menu
4) click Connect button to connect your PC to OSOYOO basic board.

5)After your PC is connected to OSOYOO basic board, please click Upload button in the bottom of your software, then the code will be uploaded to OSOYOO basic board: