Ping Library for Arduino Author: Caleb Zulawski Contact: firstname.lastname@example.org
The library below is a simple implementation that is easy to understand and great for simple testing. However, it is slow, is not meant to be run from interrupt code, and does not bound the pulseIn call by adding ", 38000" or whatever the appropriate maximum timeout (in microseconds) is for your sensor. In other words this code can introduce up to a 1 second delay as the worst case timeout to pulseIn.
|1.0a||2009-12-05||Initial Alpha Release|
Changed calibration format
|1.2||2010-08-17||Fixed incorrect files (Jesus Alonso)|
|1.3||2010-10-06||Fixed keywords.txt (Alan Carey)|
|2.0||2012-04-11||Updated for Arduino 1.0 (Cody Ketchum)|
Ping is a library for the Arduino.
Download here: Ping-2_0.zip
Ping string name = Ping(int pin, double inMod, double cmMod);
Ping ping = Ping(13);
Ping ping = Ping(13,0,0);
This initializes a Ping sensor on pin 13. The optional inMod and cmMod arguments are used to correct erroneous output by the inches() and centimeters() functions. For example, if the inches() function returns a high value, increasing inMod would correct it, and vice versa. The same applies for the centimeters() function. The default values of inMod and cmMod are 0.
This returns the amount of time in microseconds from when the sensor emits the sound to when the sound hits an object and returns to the sensor.
This returns the distance in inches between the sensor and the nearest object in front of it.
This returns the distance in centimeters between the sensor and the nearest object in front of it.
|Last Modified:||November 09, 2012, at 11:39 AM|