• 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 28 July 2025 by Admin-Lavi Leave a Comment

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:

  • Trigger pin goes to pin 9
  • Echo pin goes to pin 10

Setup:

  • Set trigger pin as output
  • Set echo pin as input
  • Begin serial communication

Loop:

  • Send short pulse from trigger pin
  • Measure how long echo pin stay high like pulse time

Use formula:

  • distance = (duration * speed of sound) / 2
  • Print distance on serial monitor
  • Speed of sound is around 0.034 cm/microsecond.

Ultrasonic Sensor Circuit Working :

Distance Measurement Circuit Diagram using Ultrasonic Sensor and Arduino

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:

  • First collect all parts like in circuit diagram.
  • Connect IC 7809 to give stable 9V DC power to Arduino.
  • Connect 10k potentiometer to LCD like this:
  • 1st pin of pot goes to LCD VDD of 5V
  • 2nd pin of pot goes to LCD VE the contrast control
  • 3rd pin of pot goes to LCD VSS the GND

Connections details of Arduino and LCD

LCD Connections:

  • LCD VDD connects to Arduino 5V
  • LCD VSS (GND) connects to Arduino GND
  • LCD RS connects to Arduino pin 12
  • LCD E Enable pin connects to Arduino pin 11
  • LCD RW connects to Arduino GND
  • LCD D4 connects to Arduino pin 5
  • LCD D5 connects to Arduino pin 4
  • LCD D6 connects to Arduino pin 3
  • LCD D7 connects to Arduino pin 2
  • LCD backlight + (anode) connects to Arduino 5V
  • LCD backlight – (cathode) connects to Arduino GND

Ultrasonic Sensor Connections:

  • Trig pin to goes Arduino pin 2 which is the output
  • Echo pin goes to Arduino pin 3 which is input
  • Vcc connects to Arduino 5V
  • GND to Arduino GND

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

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 (33)
  • Amplifier Circuits (67)
  • Arduino Projects (31)
  • Audio Circuits (93)
  • Automobile Circuits (19)
  • Battery Charger Circuits (48)
  • Free Energy (13)
  • Heater and Temperature Controllers (9)
  • High Voltage (1)
  • Indicator Circuits (38)
  • Inverter Circuits (13)
  • LDR Circuits (15)
  • LED and Lamps (116)
  • Meters and Testers (28)
  • Motor Controllers (18)
  • Oscillator Circuits (33)
  • Power Supply Circuits (92)
  • Remote Control Circuits (6)
  • Security and Protection (25)
  • Sensors and Detectors (76)
  • Solar Circuits (17)
  • Timer Circuits (30)
  • Transistor Circuits (56)
  • Transmitter Circuit (12)
  • Tutorials (5)
  • Water Level Controller (4)

Recent Posts

  • DIY Paper Recycling: Turn Old Paper into New
  • Solar Powered Mobile Charger Circuit
  • Touchless Dustbin Circuit using Arduino Uno and Ultrasonic Sensor
  • Luggage Safety Alarm Circuit using IC LM358
  • Cricket Stumps and Bails LED Indicator Circuit

Recent Comments

  1. Admin-Lavi on Constant Voltage, Constant Current Battery Charger Circuit
  2. Bill on Constant Voltage, Constant Current Battery Charger Circuit
  3. Admin-Lavi on Long Range FM Transmitter Circuit (2km)
  4. Sina on Long Range FM Transmitter Circuit (2km)
  5. Admin-Lavi on Long Range FM Transmitter Circuit (2km)

Copyright © 2025 | New Circuit Ideas