I. Objective
II. Parts and Devices
III. Hardware Installation
IV. Software Installation
V. Functional Testing and Verification
VI. Troubleshooting
In this lesson, we will use 2pcs IR distance sensors on a robot car and program the car to follow object movements. The car receives the signal from the IR distance sensors, and then the program will drive the car to take actions.
You must complete lesson 1 before you continue on with this lesson.
OSOYOO ESPro Robot car chassis x1
OSOYOO Wheels x2
OSOYOO DC motors x2
OSOYOO ESPro motor driver board x1
OSOYOO Voltage meter x1
OSOYOO MG90 servo motor x 1
OSOYOO Mount holder x1
OSOYOO Ultrasonic module x1
OSOYOO Battery box x1
OSOYOO 3pin female to female jumper wire x1
OSOYOO 4pin female to female jumper wire x1
18650 Batteries (3.7 V) x2
Battery charger x1
Step 1: Install the Espro smart car basic framework as per Espro smart car Lesson 1. If you have already completed installation in Lesson 1, just keep it as is.
Step 2: Connect 2pcs IR distance sensors modules as below connection diagram. (Remember : DO NOT remove any existing wires installed in Lesson 1).


| Open-source Arduino Software(IDE) |
![]() |
Download Arduino IDE here: https://www.arduino.cc/en/Main/Software?setlang=en |
| 7 zip is a free zip utility that un-zips zip files |
![]() |
Download 7zip here for free https://www.7-zip.org/ |
Step 1: Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip this step). Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , then install the software.
Step 2: Download https://osoyoo.com/driver/espro-2wd-car/espro-lesson5-object-follower.zip, unzip the download zip file , you will see a folder called espro-lesson5-object-follower.zip.
Step 3: Connect ESPro motor driver board to PC with USB cable, Open Arduino IDE -> click file -> click Open -> choose code “espro-lesson5-object-follower.ino” in lesson1 folder, load the code into arduino.
Step 4: Select Tool->Board->board Manager, Search ESP32 and Add ESP32 into Board Manager.
Then in Tool->Board, select esp32 ->ESP32 Dev Module,
Last select correct port which matches ESP32 board,upload the sketch to the board.


Note: When these IR modules detect objects, both the power indicator and signal indicator are on. When No object is detected, only power indicator is on, signal indicator is off. If the signal indicator is always on even though there is no obstacle in front of the sensor, you need to adjust the potentiometer.
Turn on the car, place your hand ahead of the car, then the car will move towards your hand as if you pull it. It goes forward when both IR Obstacle Avoidance modules detect your hand; it turns right if only the right IR Obstacle Avoidance module detects object; it turns left if only the left IR distance sensor detects object.
When your hand is over 10 cm ahead, it will stop.
DownLoad Url osoyoo.com