Part

Parallax PING))) ranger

Parallax’s three-pin ranger: one SIG pin triggers and echoes, 2 cm to 3 m, for the Arduino IDE’s own Ping example.

See every part
  • 3 pins
  • 1 setting
  • In 1 project
Drawn live by the editor's own code, at the size you see it.
Parallax PING))) ranger as drawn in the Mokxi simulator
At a glance

The Parallax PING))) ranger in brief

What it is, and every setting the properties panel gives it.

The PING))) is Parallax’s ultrasonic distance sensor, #28015: the same pair of 40 kHz cans as the HC-SR04 and a burst LED, but only three pins, GND, 5V and SIG. One wire does both jobs. The board drives SIG high for 2 to 5 microseconds, switches the pin to an input, and 750 microseconds later the sensor drives SIG high for as long as the sound took to reach the wall and come back, from 115 microseconds at about 2 cm to 18.5 ms when nothing answers. Sound covers a centimeter and back in about 58 microseconds, so the Arduino IDE’s Ping example divides by 29 and by 2. The sensor runs from 5 V and reaches 3 meters. In Mokxi the distance is a slider and the air temperature a property, and the IDE’s example runs as it stands.

Family
Sensors
Pins
3
temperature
20
the air in degrees Celsius, 20 by default. Sound travels at 331.3 + 0.606 T meters a second (the PING))) documentation gives the same formula), so this sets the echo time per centimeter: 29.1 microseconds each way at 20 °C, the figure the Arduino example rounds to 29.
Pins

3 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
GND
Ground.
5V
Supply, 5 V (4.5 V absolute minimum).
SIG
Both ways: a trigger in from the board, then the echo pulse out.
How to use it

How to use a Parallax PING))) with the Arduino Ping example

The PING))) has one signal pin where the HC-SR04 has two. GND goes to GND, 5V to 5 V and SIG to pin 7. The Arduino IDE’s example under File, Examples, 06.Sensors, Ping is written for exactly this wiring, and it runs here without a change.

Each pass of loop() sets pin 7 to an output, holds it low for 2 microseconds and high for 5, and drops it again: that is the trigger. Then it sets the pin to an input and calls pulseIn(pin, HIGH). The sensor waits 750 microseconds while its burst goes out, then holds SIG high until the echo returns.

The example turns that time into distance twice: microseconds / 74 / 2 for inches and / 29 / 2 for centimeters, a round trip at about 340 meters a second. Press Run and it prints 39in, 100cm for the wall the slider starts at, a meter away. Drag the slider and the numbers follow; past 3 meters the sensor gives up and sends its longest pulse, 18.5 ms, which prints as 318 cm.

The one mistake this sensor invites is forgetting the pinMode(pin, INPUT). Leave the pin an output and the board fights the sensor’s echo, so pulseIn never sees it rise. NewPing.h, given the same pin twice, and Ultrasonic.h’s one-pin constructor both do the switch for you.

Part pin
Board pin
GND
GND
5V
5 V
SIG
Pin 7

The PING))) needs 5 V, but its documentation says its SIG pin talks to 3.3 V microcontrollers too. Power it from 5 V and use any GPIO for SIG.

Parallax PING distance, the Arduino Ping examplelive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Common errors

Common Parallax PING))) ranger errors and fixes

What goes wrong
The fix
pulseIn() returns 0, or the distance never changes.
The pin was left an output after the trigger, so the echo cannot drive it. Call pinMode(pin, INPUT) right after the trigger, before pulseIn().
It always reads about 318 cm.
That is the 18.5 ms pulse the sensor sends when nothing comes back: the target is past 3 m or not facing the sensor.
It was wired like an HC-SR04 and nothing happens.
The PING))) has no TRIG and ECHO. One board pin goes to SIG and does both jobs.
Questions

Questions and answers

What is the difference between the PING))) and the HC-SR04?

They time an echo the same way, but the PING))) uses one SIG pin for the trigger and the echo, waits 750 us before the echo, and reaches 3 m. The HC-SR04 has separate TRIG and ECHO pins and reaches 4 m.

Why does the Ping example divide by 29 and by 2?

Sound takes about 29 microseconds to travel a centimeter, and the pulse is the time there and back, so the round trip is halved.

Can I use NewPing with a three-pin sensor?

Yes. Give NewPing the same pin for trigger and echo, as NewPing sonar(7, 7, 300), and it switches the pin between output and input itself.

How it is modeled

What is true about the Parallax PING))) ranger, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

The documentation's timing table, line by line:

What Datasheet Here
Trigger pulse 2 us minimum, 5 us typical A high of 2 us or more on SIG starts a measurement.
Echo holdoff 750 us SIG rises 750 us after the trigger falls.
Echo pulse 115 us to 18.5 ms The round trip, held to that window.
Delay before the next measurement 200 us SIG is driven low that long, then let go.

Between measurements the sensor does not drive SIG at all: it is listening. During the echo it drives the pin from its own 5 V, so the board must have switched the pin to INPUT by then. With nothing in range the echo is the 18.5 ms maximum, which the example prints as 318 cm. NewPing.h (one pin for both) and Ultrasonic.h (the one-pin constructor) read it too.

Not modeled

  • No sound is simulated: the slider is one number. The beam's cone, the floor echoes the documentation warns about, soft or angled targets and the reading-to-reading jitter of a real sensor are not modeled.
  • Nearer than about 2 cm the echo is the 115 us minimum, whatever is there.
  • The burst LED is drawn, not lit.
  • There is no supply current.

From Parallax PING))) ultrasonic sensor, in full.

Projects

See the Parallax PING))) ranger in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the Parallax PING))) ranger in it.

Libraries

Arduino libraries for the Parallax PING))) ranger

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Parallax PING))) ranger

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.