• 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 11 June 2026 by Admin-Lavi Leave a Comment

Ultrasonic sensor use high sound wave to find distance, also 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, as 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.

Arduino Code:

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 and Echo pin goes to pin 10

Setup:

  • Set trigger pin as output and set echo pin as input and then begin serial communication

Loop:

  • Send short pulse from trigger pi and then 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:

ComponentsQuantity
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.
  • Next, connect IC 7809 to give stable 9V DC power to Arduino.
  • After that, connect 10k potentiometer to LCD 1st pin of pot goes to LCD VDD of 5V, 2nd pin of pot goes to LCD VE the contrast control and then 3rd pin of pot goes to LCD VSS the GND

Connections details of Arduino and LCD

LCD Connections:

  • Now 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, and then LCD backlight – (cathode) connects to Arduino GND

Ultrasonic Sensor Connections:

  • Then trig pin goes Arduino pin 2 which is the output
  • After that, the echo pin connects to Arduino pin 3, which acts as an input.
  • Now Vcc connects to Arduino 5V
  • Finally, GND to Arduino GND

Note:

Speed of sound is around 0.034 cm/µs but this can change with air temperature and humidity, hence, if we need more accurate result then we can adjust this value.

Conclusion:

To conclude, by using Arduino and ultrasonic sensor we can make system to measure distance.

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

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

Filed Under: Arduino Projects, DIY 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

  • 555 Timer Projects (83)
  • Alarm Circuits (71)
  • Amplifier Circuits (91)
  • Arduino Projects (103)
  • Audio Circuits (181)
  • Automation Circuits (64)
  • Automobile Circuits (31)
  • Battery Charger Circuits (85)
  • DIY Projects (266)
  • Free Energy (12)
  • Heater and Temperature Controllers (31)
  • High Voltage (23)
  • Hobby Circuits (134)
  • Indicator Circuits (59)
  • Inverter Circuits (18)
  • IoT projects (4)
  • LDR Circuits (40)
  • LED and Lamps (188)
  • Meters and Testers (40)
  • Mini Projects (203)
  • Motor Controllers (24)
  • Oscillator Circuits (58)
  • Power Supply Circuits (205)
  • Radio Frequency (1)
  • Remote Control Circuits (11)
  • Renewable energy (5)
  • Security and Protection (89)
  • Sensors and Detectors (204)
  • Solar Circuits (31)
  • Timer Circuits (58)
  • Transistor Circuits (156)
  • Transmitter Circuit (21)
  • Tutorials (20)
  • Voltage Regulator (21)
  • Water Level Controller (10)

Recent Posts

  • Low Current Controlled Battery Charger Circuit using LM723 IC
  • 741 Op-Amp Treble Booster Circuit
  • Simple Diode and Transistor Based Audio Limiter Circuit
  • Simple 500mW Speaker Driver Circuit
  • Easy DIY LM386 Audio Amplifier Circuit

Recent Comments

  1. Tony Gallegos on NTC Thermistor Based Temperature to Voltage Converter Circuit
  2. colin on Simple Single Transistor Audio Amplifier Circuit
  3. How to Make a Bird Chirping Noise Easily on Chirping Bird Sound Generator Circuit
  4. Transistor Based Medium Impedance Preamplifier Circuit - Circuit Ideas for You on Low Impedance Input Transistor Preamplifier Circuit
  5. Admin-Lavi on Alternate Red Green LED Flasher Circuit

Copyright © 2026 | New Circuit Ideas