Site icon Circuit Ideas for You

Distance Measurement Circuit using Ultrasonic Sensor and Arduino

Ultrasonic sensor use high sound wave to find distance.

It send sound and wait for echo to come back and then it measures time.

With Arduino help we can make system to know how far object is.

This project for Distance Measurement Circuit using Ultrasonic Sensor and Arduino shows basic of ultrasonic sensor, Arduino code and steps to make distance measuring system.

Code and Explanations:

const int trigPin = 2;
const int echoPin = 3;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // Trigger the sensor
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Measure pulse duration
  long duration = pulseIn(echoPin, HIGH);

  // Calculate distance
  int distance = duration * 0.034 / 2;

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  delay(100);
}

Code explanation:

No need of extra libraries for this project.

Pick pins for sensor:

Setup:

Loop:

Use formula:

Ultrasonic Sensor Circuit Working :

Parts List:

ComponentQuantity
Resistor
Potentiometer 10k1
Semiconductors
Arduino UNO1
LCD 16X2 Display1
Ultrasonic Sensor Module1
IC 78091

Ultrasonic sensor have two parts: transmitter and receiver.

Transmission: Transmitter send short burst of ultrasonic sound.

Wave travel: Sound wave move in air and hits the object.

Reflection: When wave hit object then it bounce back as echo.

Reception: Receiver catches the echo.

Distance calculation: Time between sends and receive tell how far the object is, more time means more distance.

How to Build:

To build a Distance Measurement using Ultrasonic Sensor and Arduino follow the below mentioned steps for connections:

Connections details of Arduino and LCD

LCD Connections:

Ultrasonic Sensor Connections:

Note:

Speed of sound is around 0.034 cm/µs but this can change with air temperature and humidity.

If we need more accurate result then we can adjust this value.

Conclusion:

By using Arduino and ultrasonic sensor we can make system to measure distance.

This Distance Measurement Circuit using Ultrasonic Sensor and Arduino is useful for many things like object detection, obstacle avoid and proximity sense.

We can make smarter system by adding more sensors, displays or other parts.

References:

Distance measurement using ultrasonic sensor

Exit mobile version