Wednesday, November 27, 2019

Distance Measuring Using UltraSonic Sensor and Arduino


In this project we are going to measure distance using ultrasonic sensor and the measured distance value will be displayed on computer screen.

We will be using Processing 3 software to display the distance on the compter screen.


For this project we need
  • Arduino uno
  • Ultrasonic sensor HC-SR04
  • BreadBoard jumper wires

Theory Behind Measuring Distance

The Sensor works on the phenomenon of Echo of sound.

In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.

As speed of sound is 340 m/s (0.034 cm/us) we can calcute the received echo signal pulse duration and hence the formula for calculating distance is


Distance = (Echo pulse Duration) * 0.034 / 2


Dividing by two is done because the same wave is transmitted and received back

Connection Diagram


Arduino and Processing Code

No comments:

Post a Comment

Connect Lcd 16x2 to Arduino with just 4 wires !!!!!!

Normally connecting a LCD 16x2 to  arduino we require around 14 pins (using in 4 bit mode which is by default in arduino example sketch) ...