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

Authorized Online Retailers:

With Battery:

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

Without Battery:

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

Objective

In this lesson, you must complete lesson 4 before you continue on with this lesson. we use the ultrasonic module to “see” obstacles and measure the distance. If the distance is less than predefined threshold value, the buzzer will beep and the car will turn around from the obstacle automatically.

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

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


Software Installation:

Open-source
Software(IDE)
Download 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 IDE (If you have IDE version after 1.1.16, please skip this step). Download IDE from https://www.arduino.cc/en/software , then install the software.

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

Step 3: Connect OSOYOO Basic Board for Arduino to PC with USB cable, Open IDE -> click file -> click Open -> choose code “lesson5.ino” in lesson5 folder, load the code into 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 5 seconds.

During this first five 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 the picture below. 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 the picture below. If its direction is not straight forward, turn off the car and do direction alignment again.

Final Testing :

Power on the car, if the ultrasonic module turn to front view position, that means you no need adjust sensor position anymore. Just wait 5 seconds. If no obstacle is detected, the car will go forward. If any obstacles is detected, the car will stop, the ultrasonic module will turn from right to left to detect surrounding obstacle. The robot car will decide to make left turn, right turn or backward according to obstacle detection 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