| Buy from OSOYOO | Buy from US |
Content
In this lesson, you will transform your OSOYOO V3 Robot Car into an autonomous line-following robot.
Using a 5-channel infrared line tracking sensor array, the robot can detect the position of a black line on a light-colored surface and continuously adjust its direction to stay on the track.
Line following is one of the most fundamental technologies used in mobile robotics and automated guided vehicles (AGVs). It provides an excellent introduction to sensor-based navigation and real-time decision-making.
Before starting this lesson, make sure you have successfully completed Lesson 1: Basic Robot Car Assembly.
After completing this project, you will be able to:
| No. | Picture | Device | Qty. | Accessories | Link |
| 1 | ![]() |
Tracking sensor module | 1 | M3 Plastic Screw x 2 M3 Plastic Nut x2 M3 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 | |
| 4 | ![]() |
Hex Screwdriver | 1 | Click here to buy | |
| 5 | ![]() |
M3 plastic screw | 2 | ||
| 6 | ![]() |
M3 plastic pillar | 2 | ||
| 7 | ![]() |
M3 plastic nut | 2 |
Infrared Reflection Detection
Each tracking sensor contains two components: an infrared LED (emitter) and an infrared phototransistor (receiver).
The infrared LED continuously emits invisible infrared light toward the ground.
The amount of reflected infrared light depends on the surface color: White Surface and Black Surface. White surfaces reflect most of the infrared light. As a result:
Black surfaces absorb most of the infrared light. As a result:
This difference allows the robot to distinguish between the black track and the surrounding white background.
Step 1: Start from the robot assembled in Lesson 1. If you have already completed Lesson 2 and Lesson 3, just keep it as is.

Step 2: Remove the M3 hex screw on the upper chassis. Mount the 5-channel tracking module at the front of the lower chassis using M3 plastic screws, pillars, and nuts.
Important Notes

Step 3: Connect the GND–VCC pin of the tracking sensor module to the GND–5V of the OSOLINK WIFI/BLE I/O shield; connect IR1, IR2, IR3, IR4, IR5 pins to A0, A1, A2, A3, D13 with a 7pin 25cm female-to-female cable as shown in the photo below (Remember: DO NOT remove any existing wires installed in Lesson 1):
Step 4: Reinstall the upper chassis and tighten all mounting screws.

| Open-source Arduino Software (IDE) |
![]() |
Download software here: https://www.arduino.cc/en/Main/Software?setlang=en |
| 7-Zip is a free zip utility that unzips zip files |
![]() |
Download 7-Zip here for free https://www.7-zip.org/ |
1. Arduino IDE Setup: Download and install the latest version of the Arduino Integrated Development Environment (IDE) from https://www.arduino.cc/en/Main/Software?setlang=en.

2. Code Acquisition: Download the provided sample code for Lesson 4 from here. Extract the contents and you will get a v3car-lesson4.ino in the folder v3car-lesson4. Open the v3car-lesson4.ino sketch in the Arduino IDE.

3. Board and Port Selection: Connect the OSOYOO Basic Board (compatible with Arduino UNO) to your computer via a USB cable (Crucially, ensure the robot car’s power switch is OFF and the battery is disconnected before connecting the board to your PC). Launch the Arduino IDE. Navigate to Tools > Board and select Arduino Uno. Then go to Tools > Port and select the appropriate serial port. If unsure, check your operating system’s device manager for the assigned port.

4. Code Upload: Click the “Upload” button (right arrow icon) to compile and transfer the sketch to the OSOYOO Basic Board.
Proper calibration is essential for reliable line tracking.
Calibration Procedure
| Surface | Indicator LED |
| White background | OFF |
| Black track | ON |
Create a black line on a white surface, and place the center sensor above the black line. Turn on the robot and observe the tracking behavior.
Expected Behavior
1. Robot Cannot Detect the Line
Check:
2. Robot Frequently Loses the Line
Possible causes:
3. Robot Turns Excessively
Possible causes:
4. Ambient Light Interference
Strong sunlight may affect infrared sensors.
For best performance:
Infrared tracking sensors are most reliable under controlled lighting conditions.
DownLoad Url osoyoo.com