This project is about the use of Ultrasonic Sensors on a car to detect obstacles
Step 1: The Materials That Will Be Used
Arduino Leonardo Board
1 Servo Motor
2 Ultrasonic sensors
USB for a power source
Arduino USB Adapter
1 or more Green LED Lights
1 or more Red LED Lights
Clay (The Clay is optional; you can use other things to stick it together)
Cardboard (This is just for the outside look to wrap up the car)
Step 2: Prepare All the Materials That Were Listed
Remember that some of these materials are optional
glue or clay are optional because you can use other materials to stick, such as hot melt adhesive to stick it together.
The color of the LED lights can be changed, but remember that the colors have to be different to oberve.
The outside wrapping is optional because you can use other materials or better looking style to wrap it up.
Step 3: Put All the Wires Connected and Put It Where It Is Suppose to Be
Trigpin at 10, Echopin at 11
Trigpin2 at 6, Echopin2 at 7
Green LED Light at 9, Red LED Light at 8
The Servo Pin at 12
This is the link to how the Ultrasonic Sensors and the LED Lights are connected. Just go to the link, press “Wire” on the left-hand side and observe the connected wires and connected lines.
Step 4: Put the Materials Together
1. Make sure all the wires are connected
2. Stick the Ultrasonic Sensor with the motor together, so the Ultrasonic Sensor can detect objects while the motor turns around.
3. Stick the Arduino Leo Board on top of the bread board
4. Put the Arduino onto the Car
5. Tape the Ultrasonic Sensors onto the vehicle’s front and back
Step 5: Insert the Arduino Code
Insert the Arduino Code
This is the link to the program code on Arduino Create:
*Remember to include
The next steps will divide the code up to parts for better understandings.
Step 6: The First Part
This part of the code is clarifying the places of where the Sensors, LED lights, Motors are. For example, the trigPin of the first sensor is at number 10.
The last sentence is the range or distance that will be calculated, which is in inches.
Step 7: The Setup Part
This part shows the initializing of the Servo Motor, the Sensors and the LED pins. It starts as the Green Light is on while the red light is off.
Step 8: This Is the LOOP Part
The loop part begins with the Servo Motor turning 30 degrees, 90 degrees, 150 degrees, every 10 seconds.
Then, the two Ultrasonic Sensors are turned on and calculate the distance of (duration/2) / 29.1
Next, the IF and ELSE
If the sensors detect an object far as 5 inches, it will shine a red light
If it doesn’t detect anything less than 5 inches, it will shine the green light
Step 9: This Is the Video of the Machine in Function
The link in youtube: