# ULTRASONIC DISTANCE METER

339

1

## Introduction: ULTRASONIC DISTANCE METER

Hello everyone;

I am Amey, welcome to my channel

Today, I am building another cool project which is Measuring tape with the help of ultrasonic sensor and Arduino. So, lets' make it.

## Step 1: Components

1. Arduino Uno

2. ultrasonic sensor (HC-SR04)

3. 16 x 2 lcd

4. I2C module for LCD (Optional)

5. Laser

6. 7805

7. 9v Battery

## Step 2: WORKING

This project is really simple. I

am using an ultrasonic sensor (HC-SR04) which work on principle of doppler effect

Ultrasonic sensors work by emitting sound waves at a frequency too high for humans to hear. They then wait for the sound to be reflected back, calculating distance based on the time required. This is similar to how radar measures the time it takes a radio wave to return after hitting an object

For converting this into the distance

here the formula

distance=T*340/20000

where T is time required for wave to reflect back from object

## Step 3: CIRCUIT DIAGRAM

IN this project I use a custom made PCB you can use simple Arduino Uno in place for this

I also use i2c LCD adapter you can skip it

if you want the PCB file than comment down bellow

In above Images I use different Arduino because I cant find Arduino Uno in software so simply do connection as per image but with Arduino Uno

## Step 4: Code (with I2c Adapter)

#include

#include

#define trigger 18

#define echo 19

LiquidCrystal_I2C lcd(0x27, 16, 2);lcd.begin();

float time=0,distance=0;

void setup()

{

lcd.begin(16,2);

pinMode(trigger,OUTPUT);

pinMode(echo,INPUT);

lcd.print(" Ultra sonic");

lcd.setCursor(0,1);

lcd.print("Distance Meter");

delay(2000);

}

void loop()

{

lcd.clear();

digitalWrite(trigger,LOW);

delayMicroseconds(2);

digitalWrite(trigger,HIGH);

delayMicroseconds(10);

digitalWrite(trigger,LOW);

delayMicroseconds(2);

time=pulseIn(echo,HIGH);

distance=time*340/20000;

lcd.clear();

lcd.print("Distance:");

lcd.print(distance);

lcd.print("cm");

lcd.setCursor(0,1);

lcd.print("Distance:");

lcd.print(distance/100);

lcd.print("m");

delay(1000);

}

## Step 5: Code (without I2c Adapter)

#include

#include #define trigger 18 #define echo 19 LiquidCrystal_I2C lcd(0x27, 16, 2);lcd.begin();

float time=0,distance=0;

void setup()

{

lcd.begin(16,2);

pinMode(trigger,OUTPUT);

pinMode(echo,INPUT);

lcd.print(" Ultra sonic");

lcd.setCursor(0,1);

lcd.print("Distance Meter");

delay(2000);

}

void loop()

{

lcd.clear();

digitalWrite(trigger,LOW);

delayMicroseconds(2);

digitalWrite(trigger,HIGH);

delayMicroseconds(10);

digitalWrite(trigger,LOW);

delayMicroseconds(2);

time=pulseIn(echo,HIGH);

distance=time*340/20000;

lcd.clear();

lcd.print("Distance:");

lcd.print(distance);

lcd.print("cm");

lcd.setCursor(0,1);

lcd.print("Distance:");

lcd.print(distance/100);

lcd.print("m");

delay(1000);

}

10 2.9K
139 10K
81 9.6K
65 5.6K