top of page
Writer's pictureLearnElectronics

Object detection using Ultrasonic Sensor & Arduino

Updated: Sep 26

#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.

 




Apparatus Required


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

2. Buzzer

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.


5. Breadboard

Circuit connections are made upon this.

 

CIRCUITS:


The 4 pins of the Ultrasonic Sensor are:

  • Vcc

  • Trigger

  • Echo

  • Ground


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.


Buzzer:

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).


Circuit Diagram






CODE:







WORKING


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)






APPLICATIONS


Here are some applications for Object Detection Using Ultrasonic Sensor:

  1. Monitoring and detecting the fill level.

  2. Anti-collision detection.

  3. Vehicle detection for parking lots.

  4. People Detection.

  5. In production lines.

VIDEO EXPLANATION


Learn Electronics. (Sept 5, 2020). "Object detection using Ultrasonic sensor & Arduino". https://www.youtube.com/watch?v=HqiOpquTRW4

 

SEE ALSO:


Order Electronics Projects


Want us to guide you through your project or make the project for you? Click on the button below or reach out to us via Call/WhatsApp at (+91) - 7600948607


You can -


  • Order Basic Electronics Projects

  • Order Embedded Systems Projects

  • Order IoT Projects

  • Order FPGA Projects

  • Order VLSI Projects

  • Order Image Processing Projects

  • Order Matlab Projects

  • Order TinkerCAD Projects

  • Order Proteus Projects



Click on the button below to fill out the project inquiry form -





Create Various Projects


Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 


Follow us -


Please do follow us i.e. #learnelectronicsindia to get daily updates about new blogs, videos, courses, products, offers, competitions, quizzes, and Internship Opportunities.





1,466 views2 comments

Related Posts

See All

2 Comments


Anushka Gupta
Anushka Gupta
Jul 27, 2023

Learn Electronics India, you've truly outdone yourselves with this blog post. This was one of the most comprehensive and well-structured articles I've read on object detection using an ultrasonic sensor and Arduino. The attention to detail and the inclusion of various use cases added immense value. I can't thank you enough for sharing your expertise with the community.

Like

ashitanarvekar2002
Jul 21, 2023

Short and effective! LearnElectronics India never disappoints.

Like
bottom of page