# How to Measure Distance using Arduino (Ultrasonic)

In this article we learn how to measure distance using Arduino which makes use of Ultrasound in order to calculate distance. Assessed distance is exhibited on LIQUID CRYSTAL DISPLAY. One incorporate the use of this particular digital output info to produce numerous fascinating initiatives for instance accident resistant automobile or Robots, item locator, Sonar (recognition of materials beneath water) etc.

Sound is actually a kinetic vibration transmitted through an stretchy medium. Ultrasound tend to be involving frequencies higher than 20,000 Hz. Human being can easily only listen to somewhere around between TWENTY Hz and 20,000 Hz.

The rate at which sound moves is determined by the actual medium that it goes over as a result of. Throughout the air acceleration is somewhere around 345 m/s, inside water 1500 m/s and in a metal of stainlesss steel 5000 m/s. Therefore we are able to make use of ultrasound and also simply by determining Period we are able to obtain distance. This specific form of range locating can also be referred to as Sonar. Sonar is effective in the same way as Radar. To be able to calculate the distance of a sound travelled, it necessitates to get reflected. distance = time X velocity.

Within this project anyone will be needing Transducer and Sensors pertaining to Ultrasound Transmission and Recognition. A single this sort of Transceivers is HC-SR04 Module. Most of these units normally transmit a quick burst of ultrasonic sound in the direction of a target as well as identify sound back to the sensor. Apart from this one may require Arduino Board along with 16×2 Lcd-display.

To make this Arduino based distance measuring circuit you will need:

Arduino board

LCD module

40kHz Ultrasonic sensors

Arduino Program Sketch Code

```//programme by Mr. Syed Ali//
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int trigPin = 8;
const int echoPin = 13;

void setup()

{
lcd.begin(16, 2);
}

void loop()
{

long int duration, inches, meter;

pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);

inches = microsecondsToInches(duration);
meter = microsecondsToMeters(duration);

lcd.clear();
lcd.setCursor(0,0);
lcd.print(inches);
lcd.setCursor(5,0);
lcd.print("Inches");
lcd.setCursor(0,1);
lcd.print(meter);
lcd.setCursor(5,1);
lcd.print("Meter");
delay(1000);
}

long int microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}

long int microsecondsToMeters(long microseconds)
{
return microseconds / 2900 / 2;
}```