Authorized Online Retailers:

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

Objective

 

The installation of this lesson is based on Lesson 1 framework. If you haven't finished the assembly in Lesson 1, please review http://osoyoo.com/?p=4906 and complete the installation.

In this lesson, we will add a servo motor, an ultrasonic module and a buzzer onto Lesson 1 framework. With these new devices, the car can "see" obstacle through ultrasonic sensor 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

Hardware Installation

Step 1: Install the smart car basic frame work as per Smart Car Lesson 1 . If you have already completed installation in Lesson 1 , just keep it as is.
Step 2: Install SG90 servo motor to mount holder for servo motor with 2pcs M2*10 screws and M2 nuts (please note: cable on servo motor must face to back)


Step 3: Remove screws on copper pillars and install mount holder for servo motor at the front of upper car chassis with 3pcs M3*10 screws and M3 nuts


Step 4: Connect SG90 servo motor, OSOYOO MODEL X motor driver module and OSOYOO UNO board as following graph


Step 5: Install mount holder for Ultrasonic Module on brakect(from servo motor package) with 2pcs screws for servo motor


Step 6: Install Ultrasonic Module to mount holder with 4pcs M1.5*12 screws and M1.5 nuts


Step 7: Fix upper car chassis on low car chassis and then install mount holder for Ultrasonic Module on servo motor with screw for servo motor (Please note: please upload code to adjust servo motor direction before fixing screw for servo motor)


Step 8: Install Buzzer module at the back of upper chassis with 1pc M2.5 plastic screw, M2.5 plastic pillar and M2.5 plastic nut


Step 9: Connect ultrasonic module with OSOYOO UNO board as below connection diagram


Step 10: Connect Buzzer module with OSOYOO UNO board as below connection diagram

Software Installation:

Step 1:Download Lesson One sample code fromhttp://osoyoo.com/driver/smartcar-lesson3.zip , unzip the download zip file smartcar-lesson3.zip, you will see a folder called smartcar-lesson3 .

Step 2: Connect Arduino UNO to PC with USB cable, Open Arduino IDE -> click file -> click Open -> choose code “smartcar-lesson3.ino” in smartcar-lesson3 folder, load the code into arduino.

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

Ultrasonic sensor servo initial direction alignment

After turning on the battery, 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 5 seconds, you must make sure the Ultrasonic sensor(two eyes) is facing straight forward.

If it is not straight forward, you should turn off battery 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, turn on battery again. After hearing the long beep, 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 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 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 http://osoyoo.com/2017/05/10/arduino_car_obstacle_avoidance/#7