#Ultrasonic Sensor is used for the precise detection of objects. The ultrasonic transceivers, that are the #transmitters and #receivers, use the concept of converting electrical energy into ultrasonic sound.
The ultrasonic sensor emits sound waves at a frequency above human hearing and calculates the distance of any object or obstacle in its path. The distance is calculated by counting the time of flight, i.e., the time delay between transmitting the Ultrasonic signal and receiving it.
1. Ultrasonic sensor:
HC-SR04 model with an operating voltage of 5V,
measures distance between 2cm-40cm
accuracy of 3mm.
measuring angle = 15 degrees
operating frequency = 440Hz
Operating current < 15mA
4 pins: VCC, TRIG, ECHO, GND
A #buzzer is an audio signaling device, it can be mechanical, electromechanical, or piezoelectric.
A boundary is set within which the object can be detected when the object is within this boundary, the buzzer starts ringing, else it does not.
3. Arduino Uno R3
The #Arduino consists of digital and analog input/output pins that are interfaced with the ultrasonic sensor (used to send and receive data). the Arduino Uno IDE consists of a Serial Monitor that displays the output.
4. Jumper wires
They are used for making circuit connections.
Circuit connections are made upon this.
The 4 pins of the Ultrasonic Sensor are:
1. Vcc connected to the 5V or Arduino.
2. The trigger is connected to pin 9 of the Arduino- which is the input pin and is kept high for 10 microseconds for the initialization of measurement by sending Ultrasonic waves.
3. The echo is connected to the pin 10 of the Arduino- Output pin which will be high for the time period which is equal to the time taken for the Ultrasonic wave to return to the sensor.
4. The ground is connected to the ground of the breadboard.
1. The positive of the buzzer is connected to pin 11 of the Arduino
2. Ground connected to the ground of breadboard.
Ground: The ground of the breadboard is connected to the ground (GND) of Arduino, thereby making that line (that includes the ground of Ultrasonic Sensor and Buzzer as the common ground).
How is the Object distance calculate?
The Ultrasonic Sensor consists of a Transmitter and a Receiver. The Transmitter emits the Ultrasonic waves (signal) and the time is started when the signal is emitted. These waves spread in the air and strike the object/ obstacle in its path, after which they are reflected and returned immediately to the Receiver. once they are being returned, the timing stops. this gives us the total time of flight. We calculate the distance of the object through time.
Ultrasonic Sensor works on the basic formula of Distance = Speed x Time
The time of flight includes the distance traveled back and forth, thus we need to divide the time of flight by 2 while calculating the distance
Thus, D = S X T/2
T = time taken for the waves to hit the object and reflect. So we have divided the Time by 2 as the signal is traveling two times the distance.
S = Speed of Sound = 0.034 m/us (microseconds).
In this code, the boundary distance is set to 10 units. Whenever the object is a distance that is less than or equal to 10, the buzzer gets high and starts ringing.
Circuit Before simulation (OFF)
After simulation (ON)
Here are some applications for Object Detection Using Ultrasonic Sensor:
Monitoring and detecting the fill level.
Vehicle detection for parking lots.
In production lines.
Learn Electronics. (Sept 5, 2020). "Object detection using Ultrasonic sensor & Arduino". https://www.youtube.com/watch?v=HqiOpquTRW4