DIY INTERMEDIATE PROJECT NO.11 (DIGITAL DISTANCE METER)

Digital Distance Meter
INTERMEDIATE PROJECT

DIGITAL DISTANCE METER

USING ULTRASONIC SENSOR & ARDUINO

A simple Arduino project that measures the distance of an object using ultrasonic sound waves and displays the result on an I2C LCD and Serial Monitor.

01

AIM:

To design and build a digital distance meter using an ultrasonic sensor and Arduino that measures the distance of an object and displays it on an I2C LCD and Serial Monitor.

02

OBJECTIVE:

This project helps students understand how ultrasonic sensors work, how sound waves are used to measure distance, and how Arduino processes sensor data.

● The measured distance is shown on the I2C LCD and also on the Serial Monitor.

LEARNING OUTCOMES

Kids will learn:

➢ How an ultrasonic sensor works
➢ How sound waves measure distance
➢ How Arduino receives sensor data
➢ How Arduino calculates distance
➢ How an I2C LCD displays information
➢ How to use the Serial Monitor
03

MATERIALS PROVIDED:

1. Arduino UNO – 1 (Main Controller)
2. HC-SR04 Ultrasonic Sensor – 1 (Distance Sensing)
3. 16×2 I2C LCD – 1 (Display Output)
4. Jumper Wires – Few (Connections)
5. USB Cable / Power Supply – 1
CIRCUIT LOGIC

CIRCUIT DESIGN CONCEPT:

The ultrasonic sensor sends a short ultrasonic pulse from the TRIG pin. The pulse travels through the air, hits an object, and returns to the sensor through the ECHO pin.

01

Sound Pulse:

Arduino sends a trigger signal and the ultrasonic sensor sends ultrasonic sound waves.

02

Distance Calculation:

Arduino measures the return time of the ultrasonic wave and converts it into distance in centimeters.

CIRCUIT CONNECTIONS:

HC-SR04 Ultrasonic Sensor

HC-SR04 Pin Arduino UNO
VCC 5V
GND GND
TRIG D9
ECHO D10

16×2 I2C LCD

I2C LCD Pin Arduino UNO
VCC 5V
GND GND
SDA A4
SCL A5
STEP-BY-STEP BUILD

PROCEDURE:

01

STEP 1: SET UP THE BASE

● Place the Arduino on a flat surface or fix it inside a cardboard or plastic box.

TIP:

➔ Use double-sided tape to avoid loose connections.

ALTERNATIVE:

➔ A wooden base or thermocol sheet can also be used.

02

STEP 2: CONNECT THE ULTRASONIC SENSOR

● Fix the ultrasonic sensor on the front side so the sensor eyes face outward.

● VCC → 5V

● GND → GND

● TRIG → D9

● ECHO → D10

TIP:

➔ Keep the sensor straight for accurate readings.

03

STEP 3: CONNECT THE I2C LCD

● VCC → 5V

● GND → GND

● SDA → A4

● SCL → A5

TIP:

➔ Adjust the LCD contrast if the text is not visible.

04

STEP 4: UPLOAD THE CODE

● Connect Arduino to the computer and upload the distance measurement code.

TIP:

➔ Check the correct board and COM port before uploading.

05

STEP 5: TEST THE DISTANCE METER

● Place different objects in front of the ultrasonic sensor and observe the changing distance.

TIP:

➔ Test using a hand, book, or ruler.

HOW IT WORKS

WORKING PRINCIPLE:

01. Ultrasonic sensor sends sound waves.
02. Sound waves hit an object and return.
03. Arduino measures the return time.
04. Arduino calculates the distance.
05. Distance is displayed on the I2C LCD.
06. The same value appears in Serial Monitor.

SAMPLE CODE:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3f, 16, 2);

int trigPin = 9;
int echoPin = 10;

void setup() {

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  Serial.begin(9600);

  lcd.init();
  lcd.backlight();
}

void loop() {

  long duration;
  int distance;

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);

  distance = duration * 0.034 / 2;

  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("Distance:");

  lcd.setCursor(0, 1);
  lcd.print(distance);
  lcd.print(" cm");

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  delay(500);
}

CIRCUIT DIAGRAM:

Digital Distance Meter Circuit Diagram
PROJECT OUTCOME

FINAL RESULT:

★ Object distance is measured using the ultrasonic sensor.
★ Distance is displayed in centimeters on the I2C LCD.
★ The same reading appears on Serial Monitor.
★ The value changes continuously as the object moves.

APPLICATIONS:

1. Distance Measuring Devices
2. Obstacle Detection Systems
3. Parking Assistance Systems
4. Robotics and Automation

SAMPLE OUTPUT:

Digital Distance Meter Sample Output

Example Display:

Distance: 25 cm

The value changes when the object moves closer to or farther from the ultrasonic sensor.

ADDITIONAL NOTES:

● SAFETY:

➔ Do not short-circuit Arduino pins.

➔ Handle jumper wires carefully.

➔ Power OFF before changing connections.

● GAME / ACTIVITY CHALLENGE:

➔ Guess the distance of an object before measuring it.

➔ Compare the sensor reading with a ruler.

➔ Try to get the most accurate reading.

● CREATIVITY EXTENSION:

➔ Create a parking distance meter model.

➔ Add Green and Red LEDs for safe/close indication.

➔ Add a buzzer for an alert.

➔ Convert it into a smart dustbin sensor.

➔ Make a handheld distance measuring device.

IGNITING THE PASSION FOR ROBOTICS IN KIDS.

Leave A Comment

Your email address will not be published. Required fields are marked *