Arduino - Ultrasonic Sensor with LED's and buzzer

Picture of Arduino - Ultrasonic Sensor with LED's and buzzer
Hi guys this is my first tutorial, I've just started a few months ago learning electronics (previously I've just knew how to program in C and Python). When I finished this project (took me about 5 hours or something) I've decided to share to help anyone that is starting in electronics.

What’s this project about?
Basically we have an Ultrasonic sensor that measures the distance and the LED’s bar graph will light up according to our distance from the sensor and as we get closer the buzzer beeps in a different way. This circuit can work as a parking sensor! It's easy and cheap.

Check my website for more electronic projects and information.
Check this video to watch the circuit working

Parts Required:
1x Arduino
1x 74HC595 8 Bit Shift Register
1x Breadboard
8x LED’s (for example: 3x red, 3x yellow, 2x green)
9x 220 Ohm Resisters
1x Buzzer
1x Ultrasonic Sensor (for exemple: HC-SR04)
Jumper Wires
Remove these adsRemove these ads by Signing Up

Step 1: Let's start

Picture of Let's start
First you should place all the components on the breadboard, check the picture.

Step 2: Wires...

Picture of Wires...
Wire connection: 74HC595 8 Bit Shift Register
Ground (black wire) – Pin 8 and Pin 13
5V (red wire) – Pin 10 and Pin 16
IC Pin 11 (white wire) - Arduino Pin 11
IC Pin 12 (blue wire) – Arduino Pin 12
IC Pin 14 (gree wire)– Arduino Pin 13
1st LED (orange wire) – IC Pin 15
2nd LED (orange wire) to 8th LED – IC Pin 1 to IC Pin 8
Note this connections to the LED’s must be to their positive lead (this means the longer one)

Wire connection: LED’s
Now to the negative lead use one resistor per led and connect them to the ground (black wires)

Step 3: More wires...

Picture of More wires...
Wire connection: Ultrasonic Sensor: HC-SR04
VCC (red wire) – 5V
Trig  (violet wire) – Arduino Pin 9
Echo (yellow wire) – Arduino Pin 10
Ground (black wire) –GND

Wire connection: Buzzer
Shorter lead (black wire) – ground
Longer lead (resistor in series, red wire) – Arduino Pin 4


Nur LiyanaM3 months ago

Hi there,

I would like to ask if these circuit can be applied for detecting water level. Was it only able to detect concrete object? How about object like water? :)

hey in your schematic diagram position of echo and trig are reversed and the buzzer is not connected to d ground
RuiSantos (author)  shivamundisputed1 year ago
it's correct my schematics but the image is a bit large... (the yellow rectangle with Vcc trig echo ground)
so it's seems it's wrong... but it's working perfectly because I've received tons of emails of people that made this project and it worked!
If you have more questions just let me know
AmarA2 RuiSantos3 months ago

Amazing work Rui, I think he is trying to say that on your breadboard when you are connecting the negative side of the buzzer to ground, technically its not because there is a break in the breadboard.

psycho.maggot3 months ago

what about if without the bit shifter?.. does work or not?

janae.hickmon3 months ago

Hi. I'm having a problem with B00000000 - B11111111 being declared. The verification process is not accepting this array for some reason. Do you have any ideas as to why?

HEISENBERG_PN made it!6 months ago

More easy i'm dead! Plug & Play!
Great explains and presentation.


cobler1 year ago
the buzzer used is a 5v buzzer?or a 9v one?
cobler1 year ago
WHAT is the use of shift register here?
bqalawi1 year ago
Can you show how to connect multiple hc-sr04
in arduino with same trigger pin by using 74hc595??
tolomeo1 year ago
Could you please add how to make it independent, by using a 9v battery. I'd like to built it and install in my garage.
RuiSantos (author)  tolomeo1 year ago
I think I've answered to you through facebook, right?
if you have more questions please leave a comment on my website!
thanks so much for checking out my projects!
edgers1 year ago
My buzzer is rated 3VDC but i hear the buzzer very soft although it's working. Anything wrong with my buzzer? If i connect directly to a 3V supply the buzzer is loud.
martzsam1 year ago
Hmm... I put mine all together but all it does is light up all the LEDs and beep the same tone again and again.
RuiSantos (author)  martzsam1 year ago
hum... try to see the serial monitor and see if the distance sensor is measuring the distance properly. It can be that problem
I got it working. I had the trig and echo wires reversed.
RuiSantos (author)  martzsam1 year ago
nice I'm glad you make it to work!
frick11 year ago
sir , can you share a program of this project? :)
RuiSantos (author)  frick11 year ago
what you mean ?
If you want the source code it's on my insctructable, feel free to use it ! :)
Nice project,
RuiSantos (author)  crazy_thiago1 year ago
Thanks! I'm glad you liked it
hackery211 year ago
What if you don't want the LEDs? and want to use a vibrating motor instead of a buzzer? Just gimme some code lolz
RuiSantos (author) 2 years ago
Thanks man, I'm really glad you like, more projects soon!
rimar20002 years ago
Good work, congratulatios.