Interfacing Ultrasonic Rangefinder with AVR

HC-SR04 sensor

In this tutorial, we are going to interface ultrasonic rangefinder with the all-popular ATMEGA8. An ultrasonic rangefinder is used to find the range of an obstacle or a wall from the sensor. However, when there are cheap methods available to find a distance like the IR sensor or even a combination of LEDs and LDR would do, but the question is why we use a more expensive sensor. The reason is:- Typically the IR sensors have a detection range from 30-80 cm or even less depending upon the manufacturer and also the LEDs used. However, for an ultrasonic rangefinder, the distance can be measured accurately up to 400cm with an accuracy of 1cm. Ultrasonic rangefinders find applications to measure a level of a liquid, object sensing. Also, the great thing with this sensor is they require no calibration; no conversion from analog to digital data, and the code are is not limited to any particular manufacturer sensor. The code will work pretty much with almost all sensors available in the market.

Continue reading