Projects / HC-SR04 Ultrasonic Arduino Library

HC-SR04 Ultrasonic Arduino Library

HC-SR04 Ultrasonic Arduino Library is specifically for the HC-SR04 ultrasonic sensor. It features timing, metric conversion, and standard deviation methods, plus a few support methods. It is written in C++ to conserve the namespace. The conversion formula can be easily modified to optimize the accuracy of conversion at different distances for inches and centimeters. Multiple buffers of different lengths can be created for determining standard deviation.

Operating Systems

Recent releases

  •  08 Dec 2011 03:05

    Release Notes: This release makes the Ultrasonic library compatible with Arduino version 1.0 and up.

    •  12 Oct 2011 19:25

      Release Notes: This is the initial release.

      Recent comments

      07 Feb 2014 01:53 willianKNOWLES

      Pleace, can somebody help me to understand the use and instalation about it. I'm new in this Arduino code... thanks FOR YOUR HELP....

      29 Jul 2012 06:56 dmilly

      If you are using the arduino-1.0.1 environment, then you must replace "WProgram.h" with "Arduino.h" - works like a charm!

      13 Apr 2012 08:35 feravoon

      I think, you should set a timout for "pulseIn" in "timing" method. Because if there are multiple sensors, one sensor blocks others, because one sensor waits for an echo for a long time.

      Thanks for your effort. This library has been very helpful in my project.

      01 Mar 2012 02:11 bigern00

      I'm a newbie, so bear with me.

      When I try to verify the sketch, it gives me the following error code:

      In file included from UltrasonicDemo.cpp:1:
      /Users/sabrinawhite/Documents/Arduino/libraries/Ultrasonic/Ultrasonic.h:11:22: error: WProgram.h: No such file or directory

      How do I fix this?


      Project Spotlight


      A Fluent OpenStack client API for Java.


      Project Spotlight

      TurnKey TWiki Appliance

      A TWiki appliance that is easy to use and lightweight.