Introduction: Animated Sonic Ruler / Parking Sensor Using Arduino
## UPDATED WITH CODE, SCHEMATICS AND PARTS WITH LINKS ##
= Introduction =
Hi everyone! This is my first instructable!
After reading hundreds of instructables, I decided to make one myself!
As a brazilian, my mother language is portuguese. So, please be patient with my english.
= What did I make? =
I have built an animated Sonic Ruler using an Arduino, an HC-SR04, a buzzer, two resistors, some wires and a LCD Display. I also used an expansion module for Arduino (optional) and a breadboard. It had a very defying coding and debugging, but now I see it did worth the effort!
The mounting should be easy if you have already mounted some gadgets on breadboards, so any Arduino enthusiast can actually build it! Even begginers!
= Why did I make it? =
There are many projects so far using a HC-SR04 as a measurement gadget, but I have seen none using an animated LCD and a buzzer integrated. This one got style and personality!
My project can also be used as a parking sensor. Just by adding some meters of wire you can actually install this on your vehicle to make sure you'll never hit that wall again.
Step 1: Gathering Materials...
- 1 x Arduino UNO Rev 3 (Clone) board; @ $28.49
- 1 x HC-SR04 ultrasonic sensor; @ $2.99
- 1 x Mini-breadboard; @ $1.79
- 1 x Expansion Module for Arduino (OPTIONAL); @ $8.30 (Already comes with breadboard)
- 1 x Common buzzer; @ $3.40 (5 piece pack)
- 1 x LCD Display (16x2); @ 3.80
- 1 x 2.2K Ohm Resistor; @ 5.24 (400 piece pack)
- 1 x 220 Ohm Resistor; @ comes on the pack up ahead
- A bunch of wires/breadboard jumpers. @ 3.41 (65 cable pack)
Total cost (suposing you already have an Arduino - do the math) = LESS THAN 10 DOLLARS!!!
Step 2: Breadboard Mounting and Wiring
Mount the components using these images as guidelines. The most important thing is to make the connections as follows:
- LCD VSS pin to ground;
- LCD VDD pin to +5V;
- 2K2Ohm resistor: ends to LCD VO pin and ground;
- LCD RS pin to digital pin 9;
- LCD R/W pin to ground;
- LCD Enable pin to digital pin 8;
- LCD D4 pin to digital pin 5;
- LCD D5 pin to digital pin 4;
- LCD D6 pin to digital pin 3;
- LCD D7 pin to digital pin 2;
- LCD A pin to +5V;
- LCD K pin to ground;
- Buzzer + to 220Ohm Resistor leg and - to ground. The other resistor leg goes to pin 12.;
- HC-SCR GND to ground;
- HC-SCR Echo to pin 11;
- HC-SCR Trig to pin 10; and
- HC-SCR Vcc to +5V.
Step 3: Code & Upload
Here goes the code:
https://github.com/Raphango/Animated-Sonic-Ruler/blob/master/AnimatedSensor.ino
And the sounds library used with the code:
https://github.com/Raphango/Animated-Sonic-Ruler/blob/master/pitches.h
DO NOT FORGET TO PUT THE SOUNDS LIBRARY IN THE SAME FOLDER OF THE .INO FILE!
Attachments
Step 4: Final Thoughts
At this project you have learned how to use the HC-SR04 and the LCD with Arduino.
Feel free to make yourself one! And once you make it, why not to make it more permanent, by putting it on a PCB? Why not to embed it in a 3D printed case?
Use your creativity!
Thank you for reading!

Participated in the
Makerlympics Contest
45 Comments
8 years ago on Introduction
Nice work bro. I will try it soon. I hope I can ((:
Reply 8 years ago on Introduction
Thanks man! =D
Reply 8 years ago on Introduction
Hi , i made same project but first i tried without buzzer now im trying to use the buzzer but i cant find the code . Can you help me .
Reply 8 years ago on Introduction
The code piece for using the buzzer is already in the code available. Mind, however, that you should download the "pitches.h" file at the bottom of this instructable in order to make the buzzer work correctly.
Good luck!
Reply 8 years ago on Introduction
I made same project. But mine is telling the distance when a block appears in front of the ultrasonic sensor. You can check my project. :)
https://www.instructables.com/id/Arduino-wtv020-Sd-16P-Talking-Distance-Meter/
9 years ago on Introduction
Excellent!
4 years ago
when i connect the VCC pin of ultrasonic sensor to +5V the arduino shuts off...!!
Can u plz solve the problem...??
Reply 4 years ago
Hi!
Maybe your sensor is drawing too much current..... or it's just shorted out.
Try coneccting the VCC pin to a different source and see if it works...
6 years ago
how to put the sound library inthe same folder.i dont understand
Reply 6 years ago
The sounds library is the "pitches.h" file.
You have to put it in the same folder of the Arduino Sketch (.ino file).
Any more doubts? =)
7 years ago
Mine is saying fora do alcance, what is wrong?
Reply 7 years ago
Take a look at this fragment of code:
If your sensor gets a measure greater than 400cm or equal to 0cm, the it will show you the "Fora do alcance" text, that means that it's out of range.
I see two possible solutions for this error:
1) Check the connections; see if there's any incorrect wiring. You may use a multimeter to check the continuity of the wires. The default value for the "distance" variable is "0" so, if your sensor reading is never updated, it will give you "Fora do alcance " forever.
2) Check if your ultrassonic sensor is working properly, and if it's receiving enough voltage.
I hope it helps!
7 years ago
the sketch not work for me, please help me
Reply 7 years ago
Did you follow the steps exactly? Can you describe the problem?
8 years ago
Hi, awesome project.
I am trying to get this project on my car but I'd like to use 6 sensors and a temperature sensor (for replacing "out of range")
When I tried to add the second sensor everything become slow and doesn't work on real time.
I can post the code I made if you /anybody can help me please
8 years ago on Introduction
8 years ago on Introduction
It's so awesome...!!!!!!
I succeeded in making this.....
Thank you so much....
Where will I get the detailed working information and the function of the components???
Reply 8 years ago on Introduction
Thank you! ^^ All the info I've gathered from the internet: other instructables, google, datasheets, etc.
A good source for an overall vision at the components is the link to the site where I bought it (DX.com for the HC-SR04 and LCD Display). You'll have to look at the description of the itens.
And if you really like the subject "Sensors" (what includes the HC-SR04 ultrasonic sensor) you could buy this book (which I have and is very good).
Happy making and God Bless you!! =D
8 years ago on Introduction
Nice work ! Although if I were to make it for myself , I would get rid of all the extra shiny things and just use it to display the distance and buzz without the use of special characters and custom music. :) Any pointers as to how I would go about doing that ?
Reply 8 years ago on Introduction
LoL! xD
I just made all these extra shiny things to make the project more fancy... ^^
So... to get rid of the mario theme just delete this line of code:
//Plays intro song
playSong(0,1.30);
And to get rid of the special charachters, just remove these lines:
//Each of these "lcd.setCursor" and "lcd.write" are responsible for the drawings.
lcd.setCursor(10, 0);//This positionates the cursor on the desired slot
lcd.write(byte(0));//This writes the prefab symbols lcd.write(byte(1));
lcd.write(byte(4));
lcd.write(" ");
lcd.write(" ");
lcd.write(" ");
Mind that you might have to adjust the position of the other texts... =)