Purchase Links

Buy from OSOYOO Buy from US

Content


1Objective

In this lesson, you will transform your OSOYOO V3 Robot Car into an intelligent object-following robot. By using two infrared distance sensors mounted at the rear of the vehicle, the robot can detect nearby objects and automatically adjust its movement to follow them.

This project introduces the fundamentals of sensor-based autonomous navigation and demonstrates how robots can interact with their environment using real-time sensor feedback.
Before starting this lesson, please make sure you have successfully completed Lesson 1: Basic Robot Car Assembly.

After completing this lesson, you will learn how to:


2Parts and Devices

Make sure you have all the following parts ready before you begin.

No. Picture Device Qty. Accessories Link
1 IR Distance Sensor IR Distance Sensor 2 M3 Plastic Screw x 2
M3 Plastic Nut x 2
M3 Plastic Pillar x 2
Click here to buy
2 20-pin jumper wire, male to female, 20 cm some Click here to buy
3 Phillips screwdriver 1 Click here to buy
4 Hex Screwdriver 1 Click here to buy
5 M3 plastic screw M3 plastic screw 2
6 M3 plastic pillar M3 plastic pillar 2
7 M3 plastic nut M3 plastic nut 2

 

3How It Works

The robot uses two infrared distance sensors to detect objects positioned behind the vehicle.
Each sensor continuously checks whether an object is within its detection range. The Arduino controller reads the sensor outputs and determines how the robot should move:

Left Sensor Right Sensor Robot Action
Detected Detected Move Forward
Detected Not Detected Turn Left
Not Detected Detected Turn Right
Not Detected Not Detected Stop

Because the sensors are installed at the rear of the robot, the vehicle appears to “follow” your hand or another object as you move it.

4Hardware Installation

Step 1: Assemble the basic robot car according to Lesson 1. If your robot has already completed Lesson 2, just keep it as is.


Step 2: Remove the M3 hex screws on the upper chassis. Attach two infrared distance sensors to the rear section of the lower chassis using M3 plastic screws, plastic pillars, and plastic nuts.

Important:

Step 3: Connect the two IR distance sensors according to the wiring diagram provided below:

⚠️ 1. Do not disconnect any existing wiring installed in Lesson 1.
2. Insert the sensor wires securely to prevent intermittent signal loss during operation.

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


5Software Installation

Open-source Arduino
Software (IDE)
Arduino IDE Download software here:
https://www.arduino.cc/en/Main/Software?setlang=en
7-Zip is a free utility
that unzips zip files
7-Zip logo Download 7-Zip here for free:
https://www.7-zip.org/

1. Arduino IDE Setup: Download and install the latest version of the Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en.


2. Download the Sample Code: Download the sample code for Lesson 3 here. Extract the archive to get the file v3car-lesson3.ino inside the folder v3car-lesson3. Open the 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 (Important: make sure the robot car’s power switch is OFF and the battery is disconnected before connecting the board to your PC). Launch the Arduino IDE, go to Tools > Board and select Arduino Uno, then go to Tools > Port and select the correct serial port. If you are unsure which port to use, check your operating system’s device manager.

4. Upload the Code: Click the “Upload” button (right arrow icon) to compile and transfer the sketch to the OSOYOO Basic Board.


6Sensor Calibration

Before testing, adjust the sensitivity of both IR distance sensors.

Calibration Procedure

  1. Power on the robot and hold it in your hand.
  2. Place your hand approximately 10 cm in front of the sensor.
  3. Slowly rotate the onboard potentiometer.
  4. Watch the indicator LED.

Correct Adjustment

 

7Test the Car


After calibration, turn on the robot and place an object or your hand behind it. Slowly move the object and observe the robot’s response.

Expected Behavior:

Note:
1. Since the IR sensors are mounted at the rear of the vehicle, the robot’s movement logic is opposite to many other lessons.
2. This project only supports forward movement, left turns, and right turns. Reverse movement is not implemented in this lesson.


8Troubleshooting

1. Robot Does Not Move
Check:

2. Robot Always Moves Forward
Possible causes:

Try recalibrating the sensors.

3. Robot Turns Randomly

Check:

Both sensors should be adjusted to similar detection distances.