Introduction: Distance Measurement Using Ultra-sonic and Arduino

This project is based on RADAR system .but it can detect less distance than RADAR (only few meters).

It uses simple component like arduino nano and ultrasonic

Step 1: Component Required

Ultrasonic sensor(SR-HC 05)

Lcd 16*2

Arduino nano + cable

Printed circuit board(PCB)

Solder and jumper wire

Voltage regulator(7805)

10k potentiometer

capacitor

Bread-board +jumper wires(for Prototype)

Step 2: Hardware Setup

The hardware connection

Step 3: Software Setup

The arduino software should be installed on your computer.But arduino nano drivers are not installed during the setup installation .So you require to download additional drivers based on chip used in nano

#include <Liquidcrystal.h> //lcd library

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //connection of lcd

void setup()

{

lcd.begin(16, 2);

lcd.setCursor(0,0);

lcd.print("Distance Measurement");

lcd.setCursor(1,1);

lcd.print("Instructables!!");

delay(4000); //delay for four seconds

pinMode(6,OUTPUT); //echo pin

pinMode(7,INPUT); //trigger pin

Serial.begin(9600); //Baud rate

}

void loop()

{

long a;

long b;

float c;

lcd.clear();

lcd.setCursor(2,0);

lcd.print("Distance is");

digitalWrite(6,LOW);

delayMicroseconds(2);

digitalWrite(6,HIGH);

delayMicroseconds(10);

digitalWrite(6,LOW);

a=pulseIn(7,HIGH);

b=a/2;

c=b/29.1;

lcd.setCursor(3,1);

Serial.println(c); //display distance on serial monitor

lcd.print(c);

lcd.print(" cm"); //in centi-meters

delay(800);

}

you can download code here

Comments

author
Swansong (author)2017-08-24

Thanks for sharing :)