Buy from US | Buy from UK | Besorgen DE | Acquistare IT | Acheter FR | Comprar ES | ここでご購入を! |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In this lesson, we will install 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.
OSOYOO Mecanum wheels robotic car chassis x1
OSOYOO Wheels and motors x4 (left-wheels x2/right-wheels x2)
Raspberry pi 4B board
OSOYOO PWM HAT shield x1
OSOYOO Model Y driver board x1
OSOYOO Voltage meter x1
OSOYOO IR distance sensors x2
OSOYOO Battery box x1
OSOYOO 3pin female to female jumper wire x1
OSOYOO 6pin female to female jumper wire x2
OSOYOO 10pin female to female jumper wire x1
OSOYOO 2 pin XH2.54 female to female x1
18650 Batteries(3.7V) x2
Battery charger x1
Step 1: Install the smart car basic framework as per 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).
Step 1: Make sure you have installed rpi.gpio, PCA9685 library and enable I2C in lesson 1.
Step 2: Turn on the robot car , using SSH tools to download the python code by typing the following command in your Raspberry Pi terminal.
wget https://osoyoo.com/driver/mecanum/follower.py python follower.py
Turn on the car, put object about 10 cm ahead of each IR distance sensors and adjust potentiometer on IR distance sensors to detect object or your hand.
Turn on the car, move object or your hand ahead of car, and then the car will move accordingly: looks like you pull it. It goes forward when both IR Obstacle Avoidance modules detect object or your hand; it turns right when the right IR Obstacle Avoidance modules detect object; it turns left when the left IR distance sensors detect object.
When object or your hand is over 10cm ahead, it will stop.
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.
Run following command in your ssh terminal:
wget https://osoyoo.com/driver/mecanum/follower.py python follower.py
DownLoad Url osoyoo.com