Skip to Content

Distance Measuring Device


A Distance Measuring Device using Arduino is a versatile project geared towards accurately determining the distance between the device and an object. It typically employs sensors like ultrasonic or infrared distance sensors, which are connected to an Arduino microcontroller. The Arduino processes the data from the sensor, computes the distance based on the received signals, and presents the result. This output can be displayed on an LCD screen or communicated via serial interface to a computer or other devices. The device's functionality can be extended by incorporating additional features such as triggering alarms, controlling actuators, or transmitting data wirelessly. 


 Circuit Diagram :-



Code :-


// By Arduino Techy
					​//
#include <LiquidCrystal.h>
 
#define trigger 18
#define echo 19
 
LiquidCrystal lcd(2,3,4,5,6,7);
 
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);
 lcd.clear();
 lcd.print(" Circuit Digest");
 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);
}



Components :-

a close up of a small electronic device on a table

Arduino Uno 

 Buying Link -

https://amzn.to/3w24QWL

Ultrasonic Sensor

 Buying Link -

https://amzn.to/3UpM3ge

LCD 

 Buying Link - 

https://amzn.to/49Y8S05

Potentiometer

 Buying Link - 

https://amzn.to/3JAcYR8

Jumper Wires

 Buying Link -

https://amzn.to/3UwFaL7

Obstacle Avoiding robot