Note: ALL OSOYOO Products for Arduino are Third Party Board which is fully compatitable with Arduino

Authorized Online Retailers

With Battery:

Buy from OSOYOO Buy from USA Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!

Without Battery:

Buy from OSOYOO Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!


In this lesson, we will install an ultrasonic sensor on the robot car and program the car to keep some distance of object to move.
You must complete lesson 1 (assembling the car) before you continue on with this lesson.

Parts and Devices:

No. Picture Device Qty. Accessories Link
1 Ultrosonic Sensor 1 M1.4*8 Screw x 4
M1.4 Nut x 4
Click here to buy
2 Servo Motor 1 M2.2*8 Self Tapping Screw x 2
M2*4 Self Tapping Screw x 1
Click here to buy
3 Mount Holder for Ultrasonic Sensor 1 M1.4*8 Screw x 4
M1.4 Nut x 4
M2*4 Self Tapping Screw x 1
Click here to buy
4 Buzzer Sensor Module 1 M3 Plastic Screw x 1
M3 Plastic Nut x 1
M3 Plastic Pillar x 1
Click here to buy
5 20pin 15cm Female to Female Cable 1 Click here to buy

Hardware Installation

Step 1: Install the smart car basic framework as per Lesson 1 . If you have already completed installation in Lesson 1 , just keep it as is.

Step 2: Install servo motor at the front of car chassis with 2pcs M2.2 * 8 Self Tapping Screws as following:

Step 3: Install ultrasonic module to mount holder with 4pcs M1.5 * 8 screw and M1.5 nuts

Step 4: Install mount holder for Ultrasonic Module on servo motor with M2 * 4 Self Tapping screw

Step 5: Install buzzer module on car chassis with 1 pc M3 plastic screw, M3 plastic pillar and M3 plastic nut

Step 6: Connect SG90 servo motor to OSOYOO Motor Shield as following diagram (Remember : DO NOT remove any existing wires installed in Lesson 1 ) :

Step 7: Connect ultrasonic module with OSOYOO Motor Shield as below connection diagram:

Step 8: Connect buzzer module with OSOYOO Motor Shield as below connection diagram

Software Installation:

Download  IDE here:
7 zip is a free zip
utility that un-zips zip files
Download 7zip here for free

Step 1: Install latest IDE (If you have IDE version after 1.1.16, please skip this step). Download IDE from , then install the software.

Step 2: Download sample code from Lesson 4 sample code , unzip the download zip file, you will see a folder called lesson4.

Step 3: Connect OSOYOO Basic Board for Arduino to PC with USB cable, Open IDE -> click file -> click Open -> choose code “lesson4.ino” in lesson4 folder, load the code into OSOYOO Basic Board for Arduino. (Notice: Shut off your battery or Unplug your power adapter when upload sketch code to OSOYOO Basic Board for Arduino.)

Step 4: Choose corresponding board/port for your project,upload the sketch to the board.

Step 5: Ultrasonic sensor servo initial direction alignment

After power on the car, you will hear a long beep sound, then the servo will make some movement and finally stops at a direction for 2 seconds.During this first 2 seconds, you must make sure the Ultrasonic sensor(two eyes) is facing straight forward.

If it is not straight forward, you should turn off the car immediately and remove the sensor from 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, power on the car again. After hearing the long beep, the sensor should face front same as following picture. If its direction is not straight forward, turn off the car and do direction alignment again.

Final Testing :

Turn on the car, move an object or your hand in front of the ultrasonic module, and then the car will move in some distance of object or your hand. when you close the car, the car will move back, just as it says don’t touch me.
When object or your hand leave the ultrasonic module, the car will stop moving.