I.Objective
II.Parts and Devices
III.Hardware Installation
IV.Software Installation
VI.How to play
Trouble Shooting
Buy from US | Buy from UK | Besorgen DE | Acquistare IT | Acheter FR | Comprar ES | ここでご購入を! |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In this lesson, we will do an obstacle avoidance auto-driving project. We use an ultrasonic module to “see” the obstacle, and the car will turn around from the obstacle automatically.
You must complete lesson 1 before you continue on with this lesson.
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 MG90 servo motor x 1
OSOYOO Ultrasonic sensor module x1
OSOYOO Mount holder x1
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 XH.25 female to female x1
18650 Batteries(3.7V) x2
Battery charger x1
1)Install Ultrasonic Module to mount holder with 4pcs M1.5*8 screw and M1.5 nuts.
2)Install mount holder for Ultrasonic Module on servo motor with M2*4 Self Tapping screw.
When placing the ultrasonic underneath, as the self-tapping screws easily strip.
A. Support the motor from underneath, as the self-tapping screws easily strip.
B. Do not insert the screw until after the alignment process.
3)Please keep all lesson 1 connections same as it is.
Connect SG90 servo motor and ultrasonic module to OSOYOO Uart Wi-Fi shield as follows.
Note: You need to split 4 pcs of female-to-female jumper wires from our 10-pc jumper wire bundle. Any color from the bundle will be ok. The rest wires are as spare parts for potential broken or damaged wires.
Connect raspberry pi 4 via USB-C cable from PC, Open PuTTY and enter the IP address (or Host Name pi ) and 22 under Port (by default it is 22) ,then click open.
Use ssh tool to control Raspberry Pi remotely on other OS PC, run Sample Code by following command:
wget https://osoyoo.com/driver/mecanum/mecanum_oa.py python mecanum_oa.py
The servo will make some movement and finally stops at front direction for 3 seconds.
If the ultrasonic sensor does not face the front during this first 3 seconds, you should turn off battery immediately and remove the sensor from the servo, reinstall it and make it facing straight forward direction as following picture. Otherwise, the obstacle avoidance program will not work properly.
After adjusting sensor direction, turn on battery again, the sensor should face front same as following picture. If its direction is not straight forward, turn off battery and do direction alignment again.
Final Testing :
After turning on the battery switch on the battery box, if the ultrasonic module turn to front view position, that means you don’t need to adjust sensor position anymore. Just wait 3 seconds. If no obstacle is detected, the car will go forward. If any obstacles are detected, the car will stop, the ultrasonic module will turn from right to left to detect surrounding obstacles. The robot car will decide to make left turn, right turn or backward according to obstacle sensor data and our obstacle avoidance algorithm.
Sometimes your car might have collision and make your Ultrasonic sensor position change, you must remember to do sensor direction alignment again as per link Ultrasonic sensor servo initial direction alignment.
Use ssh tool to control Raspberry Pi remotely on other OS PC, run Sample Code by following command:
wget https://osoyoo.com/driver/mecanum/mecanum_oa.py python mecanum_oa.py
DownLoad Url osoyoo.com