Ping Library

The Ping library, by Caleb Zulawski, let you use the Parallax Ping))) ultrasonic sensor to make distance / range measurements.

Download: Included with the Teensyduino Installer

Hardware Requirements

Ping requires just 1 pin, and power.

Parallax Ping))) connected to Teensy 2.0

Basic Usage

Ping myPing = Ping(pin);

Create an instance of the Ping library. You can connect many "Ping)))" sensors, with each on its own pin, and create instances of the library for each.;

Make the ultasonic measurement.


Read the measurement in microseconds.


Read the measurement, converted to inches.


Read the measurement, converted to centimeters.

Example Program

Open the example from File > Examples > Ping > Ping_Library_Example.

Ping Measuring 3 Inch Distance

#include <Ping.h>

Ping ping = Ping(13);  // Ping signal on pin 13

void setup() {

void loop(){;
  Serial.print("Microseconds: ");
  Serial.print(" | Inches ");
  Serial.print(" | Centimeters: ");

Using Teensy 3.0 with 5 Volt Ping

The Parallax Pin requires 5 volt power, which can be taken from Teensy 3.0's VIN or VUSB pins.

A Ping sensor was tested with Teensy 3.0 to determine if it strongly drives the pin with 5 volts. The result appears to be Ping driving approximately 3.9 volts into the Teensy 3.0 pin. Using a 470 ohm or 1K resistor in series with the Ping signal may be wise (to limit the current Ping could inject into Teensy 3.0's built-in protection diodes), but at least the Ping output is not so strong to force Teensy 3.0's pin beyond 3.9 volts.

Teensy 3.0: Start Pulse is 3.3 Volts, Response Pulse is 3.9 Volts.

More Details

Please refer to the official Ping library documentation for more details.