Distance Measurement Using Ultra-sonic and Arduino

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    Discussions

    0
    Swansong
    Swansong

    2 years ago

    Thanks for sharing :)