Introduction - Working - Interfacing Ultra Sonic HC-SR04 Sensor

Hey Guys,

In this post we will see, basic features of ultrasonic sensor, and how to interface it with a microcontroller.


  • Principle of Operation:-
* Make use of US waves.
*Consists of a tramistter part  and a receiver part.
*Transmitter sends US waves,  After detecting any obstacle,  waves travel back.
*Receiver captures returning waves.
*Time taken for the travel is obtained and distance towards object 
  is calculated by,

D=(t*340)/2  

D=Distance
t=Total time




  •  Pin Description:-

PIN 1 - VCC - 5v Supply
PIN 2 - Trigger pin - To activate sensor.
PIN 3 - Echo pin - High value for whole wave transmission.
PIN 4 - GND - Ground pin.


  • Working:-

* A pulse of time period greater than 10us is applied to trigger pin.
* Transmitter will transmit US waves and echo pin will go high.
* Run a timer during high pulse of echo pin.
* When the receiver receives US waves echo pin goes low,timer is stopped.
* Distance is calculated from timer value.


  • Interfacing with Micro-controller:-

* Connect echo pin to an interrupt pin in micro-controller.
* Connect trigger pin to any of output pin.
* Generate a pulse of time period greater than 10us and apply to trigger.
* Start a timer with echo pin as its control.
* Calculations based on timer value.


  • View as Slideshow :-


  • View as Video :-



For more articles related to technology - click here

Popular posts from this blog