Measure Distance With Ultrasonic Sensor!

Have you ever wondered how Obstacle Avoiding Cars work? Or How can you measure the distance of an object with a sensor? In today’s article, we bring you detailed documentation on How can you measure the distance of an object with sound waves. Moreover, you will learn to make a simple yet cool parking system in this article.

Ultrasonic Sensor

An ultrasonic sensor is an electronic device that measures distance by using ultrasonic waves. It is an application of SONAR (Sound Navigation and Ranging). Ultrasonic Sensors measure the distance to the target by measuring the time between the emission and reception.

Working of Ultrasonic Sensor

One end of the Ultrasonic Sensor is a transmitter, and the other is the receiver. When we initiate the trigger pin, it emits ultrasonic waves. If there is an obstacle in the way of these waves, ultrasonic waves bounce back and diffract to the receiver end of the Ultrasonic Sensor. When these waves fall on the receiver, the echo pin initiates and generates a pulse. Arduino senses this pulse and notes the time between emission and reception of sound waves.

Making Parking System

Required Components

The components required to make this project are:

1.       Arduino Board

2.       Ultrasonic Sensor

3.       Jumper wires

4.       Breadboard

5.       Buzzer

Code

Following is the code for this project. Uncomment the commented code to make parking system, but If you want to simply operate an ultrasonic sensor to measure the distance, keep that section commented.

Circuit Diagram

Connect the components as shown in the Circuit Diagram.

Points to Ponder

·         Why can’t we hear these waves?

Human audible frequencies range from 20Hz to 20k Hz, while Ultrasonic Sensor operates at frequencies greater than 20k Hz. Hence, these frequencies are inaudible for humans.

·         How do we get Distance Formula, used in code?

Ultrasonic Sensor gives us time. The speed of sound in the Ultrasonic sensor is around 343 m/s. By using the formula S=vt, we can find the distance. But here we need to put in a few considerations.

1.       Time obtained from the ultrasonic sensor is for complete wave, we only need half of it. (t/2)

2.       The time obtained from Ultrasonic Sensor is in milliseconds, we need to convert it in seconds-to match dimensions with speed of sound, which is in m/s.

The expression we will get at the end is:

S= (t/2)(343/1000)=(t/2)(34.3)

*Important: We have used (t/2)(29.1) because the speed of sound can vary depending on the manufacturer and the environment in which you are operating it. Temperature and Humidity play a role in changing the speed of sound. If you don’t get the desired accuracy, play with this value, until you find the perfect match.  

EndNote

For more detail and a hands-on experience, watch our video. If you liked our effort, subscribe to our channel and share it with your friends. You can also subscribe to our newsletter by clicking the subscribe button above, and get an email notification every time we upload a new article.

Thanks for your time. Happy Learning!


Comments

Popular Posts

How To Make Line Follower Using Three IR Sensor | Arduino Line Following Car

How To Make Line Follower Car with Speed Control | 6 IR Sensor Arduino Line Following Car