• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » Distance Measurement Circuit using Ultrasonic Sensor and Arduino

Distance Measurement Circuit using Ultrasonic Sensor and Arduino

Last updated on 20 August 2024 by Admin-Lavi Leave a Comment

Ultrasonic sensors use high-frequency sound waves to detect distance, then they measure the time it takes for the echoes to bounce back.

When combined with the Arduino microcontrollers computing capacity, we can build a system that can precisely calculate an objects distance from us.

This assignment will examine the fundamentals of ultrasonic sensors, the necessary Arduino code and the procedures for constructing a system for measuring distance.

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);
}
  • Add the required libraries for this project, there are no external libraries needed.
  • Describe pin decide on pin numbers for the echo and trigger pins.
  • Setup is assign the output pin to the trigger.
  • Choose input for the echo pin.
  • Start the serial communication process.
  • Loop gives the sensor a trigger pulse.
  • Calculate how long the echo pulse lasted.
  • Use the following formula to calculate the distance:
  • distance = (duration*speedofsound)/2
  • Print the distance to the serial monitor that was determined.

Ultrasonic Sensor Circuit Working :

Distance Measurement Circuit Diagram using Ultrasonic Sensor and Arduino

Parts List:

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

A transmitter and a receiver are the two transducers that are usually found in an ultrasonic sensor.

Transmission is a brief burst of ultrasonic waves is released by the transmitter.

Waves propagate across the atmosphere until they come into contact with an item.

Reflection is the waves create an echo when they strike an item and return.

Reception is the returning echo is picked up by the receiver.

Calculating distance is the distance to an object is exactly proportional to the amount of time that passes between sending a signal and receiving an echo.

How to Build:

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

  • Gather all the components as shown in the above circuit diagram.
  • Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board
  • Connect pot 10k 1st pin to VDD (5V) pin of LCD display board, 2nd leg of pot 10k to VE (contrast) pin of LCD display board and 3rd leg of pot 10k to VSS (GND) pin of LCD display board.

Connections details of Arduino and LCD

  • Connect LCD VDD to Arduino 5V
  • Connect LCD VSS GND to Arduino GND
  • Connect LCD RS register select to Arduino digital pin 12
  • Connect LCD Enable E to Arduino digital pin 11
  • Connect LCD RW Read/Write to Arduino GND
  • Connect LCD D4 to Arduino digital pin 5
  • Connect LCD D5 to Arduino digital pin 4
  • Connect LCD D6 to Arduino digital pin 3
  • Connect LCD D7 to Arduino digital pin 2
  • Connect LCD backlight anode to Arduino 5V
  • Connect LCD backlight cathode to Arduino GND

Connections details of Ultrasonic Sensor:

  • Connect Trig pin to a digital output pin on the Arduino pin 2
  • Connect Echo pin to a digital input pin on the Arduino pin 3
  • Connect Vcc to the 5V pin on the Arduino.
  • Connect GND pin to the ground pin on the Arduino.

Note:

The estimated speed of sound, which is 0.034 cm/µs, is a rough figure that might change based on the air temperature and humidity.

You might need to modify this number for measurements that are more exact.

Conclusion:

Through the integration of an Arduino board and an ultrasonic sensor, we can effectively develop a distance measurement system.

The foundation for several applications, including as proximity sensing, object identification and obstacle avoidance, is provided by this research.

More sophisticated systems can be created by adding more sensors, displays or actuators for further improvements.

References:

Distance measurement using ultrasonic sensor

Filed Under: Arduino Projects, Sensors and Detectors

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « LPG Gas Leakage Detector Circuit using Arduino
Next Post: Simple LED Flashing Circuit with Arduino Uno »

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Categories

  • Alarm Circuits (30)
  • Amplifier Circuits (67)
  • Arduino Projects (29)
  • Audio Circuits (93)
  • Automobile Circuits (19)
  • Battery Charger Circuits (48)
  • Free Energy (13)
  • Heater and Temperature Controllers (9)
  • Indicator Circuits (38)
  • Inverter Circuits (13)
  • LDR Circuits (13)
  • LED and Lamps (111)
  • Meters and Testers (27)
  • Motor Controllers (18)
  • Oscillator Circuits (32)
  • Power Supply Circuits (91)
  • Remote Control Circuits (6)
  • Security and Protection (23)
  • Sensors and Detectors (71)
  • Solar Circuits (16)
  • Timer Circuits (27)
  • Transistor Circuits (56)
  • Transmitter Circuit (12)
  • Tutorials (4)
  • Water Level Controller (4)

Copyright © 2025 | New Circuit Ideas