Distance Measurement using Ultrasound sensor Program with Component Connection

Objective:

         To measure the distance of the object present

Components Required

  • Arduino Uno
  • Ultrasound Sensor

Connection Diagram

Program

int trigPin = 2, echoPin = 3;

long duration;

int distance;

void setup()

{

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

Serial.begin(9600);

}

void loop()

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

Serial.print(“Distance: “);

Serial.print(distance);

Serial.println(” cm”);

delay(1000);

}

Working

         The ultrasound sensor has a Transmitter and a Receiver. The transmitter transmits the ultrasound wave and the receiver used to receive the  wave reflected by the object in front of it. The time difference between the Transmitted and the Received wave is calculated and also the velocity of the sound wave is 340 m/s. So that the distance of the object can be easily calculated using the formulae

Distance = Velocity x Time

Output

Distance of the object : 100

Interfacing LCD with Arduino Uno Program with Component Connection
Interfacing IR Receiver with Arduino Uno Program with Component Connection

Leave a Reply

Your email address will not be published. Required fields are marked *

Navigation

My Cart

Close
Viewed

Recently Viewed

Close

Great to see you here !

Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our privacy policy.

Already got an account?

Quickview

Close

Categories