Purchasing link

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

Content


1Objective

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:

2Parts and Devices:

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

3Line Tracking Sensor Working Principle

Infrared Reflection Detection

Each tracking sensor contains two components: Infrared LED (Emitter) and 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.

4Hardware Installation

Step 1: Start from the robot assembled in Lesson 1. If you have already completed Lessons 3, please remove the wires which you connected in lesson3.

Step 2: Remove the M3 hex screen on 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 GND-VCC pin of tracking sensor module to GND-5V of OSOYOO Uart WiFi shield V1.3; connect IR1, IR2, IR3, IR4, IR5 pins to A0, A1, A2, A3, D13 with 7pin 25cm female to female cable as the following photo shows (Remember : DO NOT remove any existing wires installed in Lesson 1 ):

Step 4: Reinstall the upper chassis and tighten all mounting screws.

5Software Installation

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 7zip 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.

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 connect 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: Open the v3car-lesson4.ino sketch in the Arduino IDE. Click the “Upload” button (right arrow icon) to compile and transfer the sketch to OSOYOO Basic Board.


6Sensor Calibration

Proper calibration is essential for reliable line tracking.

Calibration Procedure

  1. Power on the robot, and hold your robot car.
  2. Place the sensor over a black line on white surface.
  3. Adjust the onboard potentiometer using a small screwdriver.
  4. Observe the indicator LED.
Surface Indicator LED
White background OFF
Black track ON

7Test the Car

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.

Recommended Specifications of track

Expected Behavior

8Troubleshooting

1. Robot Cannot Detect the Line

Check:

2. Robot Frequently Loses the Track

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.