Tag Archives: Distance Measure

Arduino Tutorial 61: Improving Precision of Your Distance Measurements

HC-SR04
HC-SR04 Ultrasonic Sensor in a Distance Measuring Project

In this lesson we strive to improve the precision of our distance measurements using an average of a large number of measurements. This builds on the work we did in the last few lessons.

We are building this with parts from our Elegoo Kit , and our actual build is using an Arduino Nano, which allows the project to be built on a single breadboard. You can get the neat jumper wires HERE.

This video takes you through the process step-by-step.

The code developed in this video is included below for your convenience.

 

Arduino Tutorial 59: How To Build a Portable Distance Sensor Ultrasonic Sensor

Ultrasonic Distance Sensor
This is our completed build of a portable, ultrasonic distance sensor.

This Lesson picks up where Tutorial 55 left off. You want to take the basic distance measurement capability you built, and make it portable. In order to make it portable, you will need to add an LCD display, and figure out a way to power it. The easiest way to get portable power is to connect the Arduino to a USB power bank.

The sensor is part of our Elegoo Kit , so if you get this kit, you will be using the same hardware we are using.

A challenge with this project is to keep your build nice and neat, as there are lots of connections, and if any are not completely secure, you will get unpredictable performance in your device. For this build we will be using an Arduino Nano, which allows the project to be built on a single breadboard. You can use the Arduino Uno if you do not have a Nano, and things will work out the same. The build neatness is also facilitated by using small straight jumper wires, which you can get HERE.

The first task will be to lay out your components in preparation for the build. Carefully consider all the connections you will have to make, and then organize so that the connections can be made with minimum confusion. This means minimize the number of crossing wires, and try to have needed connections in the same general area.

The LCD will need to be wired up according to the following Schematic:

Arduino LCD Schematic
This schematic will allow you to connect the LCD to the Arduino

Now, you will also need to connect the HC-SR04 Ultrasonic Sensor.

HC-SR04 Pin Arduino Pin
VCC 5 V
GND GND
Trig digital 2
Echo digital 3

This video takes you through the build and programming step-by-step.


In this video we developed the following code: