What is Ultrasonic Sensor HC-SR04?This is the HC-SR04 ultrasonic ranging sensor. The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do.This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. The operation of sensor is not affected by sunlight or black material like sharp range finders do. Each HC-SR04 module includes ultrasonic transmitter, receiver module and a control circuit. The sensor uses sound rather than light for detection. Ultrasonic sensors are great solutions for clear object detection, clear label detection.There are only four pins that you need to worry about on the HC-SR04: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground).FeaturesPower Supply: +5V DCQuiescent Current: <2mAWorking Current: 15mAEffectual Angle: <15°Ranging Distance: 2cm – 400 cm/1? – 13ftResolution: 0.3 cmMeasuring Angle: 30 DegreeTrigger Input Pulse width: 10uSLow costStable performance.   Sensor: HC-SR04 PinsVCC: +5VDCTrig : Trigger (INPUT)Echo: Echo (OUTPUT)GND: GND                        Working:The sensor works on the principle of 'echolocation' , yeah the same technique that allows the bat and whales to see. The wave(pulse) is generated from the sensor trig pin using the Arduino and the pulses return to the sensor after striking an object to the echo pin which transfers the digital(0,1) if the object is detected and approx distance of object from the sensor can be noted via Serial port terminal.The trig wave is generated from the sensor of 1ms duration in our program i.e. the width of pulse is 1ms which is acquired using the function pulse In() and saved in the variable duration . The pulse travels at the speed of sound about 340m/s and the duration is double the time taken by the wave to reach the object (since it bounces back and then noted via echo pin). So distance will be duration * speed . Advantages:Multipurpose: the HC-SR04 is used for Mesurment detection,Object detection, etc.Configuration: the HC-SR04 can be quickly reconfigured completely via software.Initialization: can be pretty fast on the HC-SR04 (2-3 seconds).Cost: HC-SR04 is low cost sensor.Operate: easy to operate.Disadvasntages:Sensing cone: the cone of HC-SR04 is very few degrees wide vertically and less than 30 degrees horizontally.We can measure distance only of stationary objects.