Ping Library for Arduino Author: Caleb Zulawski Contact: caleb.zulawski@gmail.com
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.
If you need more efficient code that can be run from interrupts and can be used to talk to multiple sensors at the same time, look at NewPing from http://code.google.com/p/arduino-new-ping/
Release | Date | Changes |
---|---|---|
1.0a | 2009-12-05 | Initial Alpha Release |
1.1 | 2009-12-06 | Formal 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.
The Ping library simplifies the usage of the Ping))) Ultrasonic Sensor with Arduino. It is an implementation of the concepts provided in the Arduino Ping))) tutorial.
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 |
By: | marcmerlin |