Spelchan.com Logo

Electronic Measuring Tool

Measuring Tool circuit

Video demonstration

Source Code

Source code for Arduino Studio

About Measuring

The HC-SR04 sonar is a simple circuit that transmits sound then waits for the echo. The circuit simply consists of a trigger pin to start the transmission, an echo pin for receiving the transmission, and your voltage and ground. The LCD display is a bit more complicated but most of the complexity is handled through a Liquid Crystal library that is commonly used. This simply requires that you specify which pins to use for the four data lines (D0 through D3), the display enable pin (E) and the Register Select pin (RS) when creating an instance of that object.

The button is used to switch between my 3 different display modes. The code simply detects a button push and loops between the three states of the display. I am using micro seconds, inches, and centimeters though the constant values used for those three were not properly calibrated so you may need to adjust the constants that I have used for those measurements.

The idea is that you send out a ping and the time for the echo to return is the time you use for determining how far away the object is. The distance is essentially the time it takes for the sound to return divided by two as you are going to the object then returning.