PING))) Wiring & Example Code

The Ping))) Ultrasonic Distance Sensor measures the roundtrip echo time of ultrasonic sound to determine how far away an object is. It can measure distances anywhere from 3 centimeters to 3 meters. In addition to being a great distance sensor for robots, it’s also useful for detecting people passing through doorways, viewing art exhibits, approaching holiday props, and more.

Wiring & Connections

Parallax PING))) Ultrasonic Distance Sensor (left) and Parallax Laser PING (right).

ActivityBot Alert! Use a different I/O pin if your board is on a robot—P15 is already in use by a servo on the P15 servo port.

     

  

Use a 2 k-ohm resistor (red-black-red) between the PING))) sensor’s SIG pin and the Propeller I/O pin. 

 

Quick Code Example

Using the connections shown in the wiring diagram above, this example will display PING))) distance measurements in the Terminal Window.