This is a simple guide on how to make a distance detector using an Arduino, a HC-SRO4 Ultrasonic Sensor, a Buzzer, and some LED's.  The ultimate goal of this tutorial is to use the buzzer and LED's to display how far the object is from the ultrasonic sensor.

Step 1: Materials Needed

The Materials needed for this project are:

(1x) Arduino Uno
(1x) Breadboard
(1x) HC-SRO4 Ultrasonic Sensor
(1x) Buzzer
(2x) Green LEDs
(2x) Yellow LEDs
(2x) Red LEDs
(7x) 330 ohm Resistors
A lot of jumper wires
<p>Thanks mate this is really works.</p>
<p>Thanks mate this is really works.</p>
<p>Thanks brah!</p>
<p>thank you very much!!!!!!!!!!!!1 it&acute;s great and fantastic!!!!!!!!!!! =)</p>
<p>Really interesting project. Worked exactly as promised! Thanks. :)</p>
Easy and useful project :)
<p>This was my first project from this site so thank you very much! </p>
<p>Works just as promised </p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/xF7It_x4F20" width="500"></iframe></p><p>Link for Video</p>
worked perfectly , just what i wanted thanks a lot!
<p>Hi, I am going to build a robot with four of these distance sensors.I like the simplicity of the code compared to others, but there is one flaw. I have already modified the void setup for my sketch with no problems, but I was wondering about the &quot;if&quot; statements. Is there any way to differenciate between the sensors, so that I can tell which sensor I am getting a reading from? I have included the following piece of your code to show you what I mean:</p><p><br> if (distance &lt;= 30) {<br> digitalWrite(led, HIGH);<br> sound = 250;</p><p>I want to know which sensor I am getting this information from.</p>Other than that, I really like this piece of code and if <em>I can get this cleared up, I will definitely use it.</em><p>(Sorry for the bold lettering, I accidentally highlighted it and made it bold and don't know how to get it off.)</p><p>Thanks </p>
<p>Sorry for the late response. The distance variable (along with the duration variable) are all based on the pulseIn() command, that reads data from echoPin. That echoPin is connected to the sensor. In your setup, you are going to need multiple trigPins, pulsePins, durations, distances, etc. Essentially you will need an entire copy of the loop routine for every sensor you have.</p>
<p>its works like charm man, thanks. but if want to measure from far distance, don't forget to change the code.</p>
<p>Could you please tell me how to modify this circuit and code for a 10 led bar graph display, while using a Parallax PING))) sensor and buzzer. Thank you.</p>

About This Instructable


95 favorites


More by flynn_munroe: Arduino Distance Detector with a Buzzer and LED's
Add instructable to: