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

In this lesson, we use our Raspberry Pi robot car to automatically drive along  a black line in white ground . We will use 5-point IR tracking sensors to detect the line.

No. Picture Device Qty. Accessories Link
1 Tracking sensor module 1 M2.5 Plastic Screw x 2
M2.5 Plastic Nut x2
M2.5 Plastic Pillar x 2
Click here to buy
2 7pin 25cm Female to Female Cable 1 Click here to buy
3 Philips screwdriver 1 Click here to buy

Step 1: You must complete Lesson 2 basic frame work

Step 2: Install tracking sensor modules under lower car chassis with 2pcs M2.5 plasctic screws, M2.5 plastic pillars and M2.5 plastic nuts.

Step1: Connect GND-VCC pin of tracking sensor module to GND-5V of osoyoo PWM HAT board ; connect IR1, IR2, IR3, IR4, IR5 pins to GPIO5, GPIO6,  GPIO13, GPIO19, GPIO26 of Raspberry pi with 7pin 25cm female to female cable as the following photo shows (Remember : DO NOT remove any existing wires installed in Lesson 1 ):

Step 2: Adjust the sensitivity of tracking sensor modules.

Turn on and hold the car and adjust the potentiometer on the tracking sensor with Philips screwdriver until you get the best sensitivity status: the signal indicate LED light will turn on when sensor is above black track, and the signal LED will turn off when the sensor is above white ground.

Download the python code by typing following command in your Raspberry Pi terminal:

wget http://osoyoo.com/driver/servo-steer-car/pi-tracking.py


Turn on the battery of your car and put the car on the black track line:
Now you can run the line tracking python program by typing following command:

python pi-tracking.py

Your car will move along the black track line.