Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Ultrasonic SR04 library for Arduino
by LunaX - 2010/2011

CURRENT VERSION

Release 1.0 24-FEB-2012 beta version.

HISTORY

Release 1.0 24-FEB-2012 Initial Release

DESCRIPTION

Easy to use ultrasonic library based on SR04 sensor.

HOW TO IMPORT/INSTALL

Download latest zip file here http://getfiles.co/1rcR

Put the SR04 folder in "libraries\".

Open example project which is included in the zip file. Try it, like it :-) This example use my other library "Logging". Please download it too.

Methods for measuring

MethodeComment
Distancereturn distance in centimeter
DistanceAvgdo several measurments, return average
Pingsend only a ping signal
getDistanceget latest distance in centimeter