The PING))) measures the round-trip echo time of ultrasonic sound to determine how far away an object is, and can measure distances anywhere from 3 centimeters to 3 meters. In addition to being a great distance sensor for robots, the PING))) is also useful for things such as detecting when a person passes through a doorway, approaches art exhibits, and walks near holiday props.
Want to go a bit more in depth? Check out this article about the speed of sound vs. air temperature [1], and learn how the temperature of your environment can impact distance measurements from your PING))) sensor.
The PING))) sensor only needs three connections to do its job: I/O pin, power, and ground. The connections are easily accessible at the Hacker Port, making for a simple hacking project with the S3. BlocklyProp makes programming the PING))) simple and fun.
To complete this tutorial, you will need these parts:
Let's have some fun in BlocklyProp and test some code. This particular code will display the distance in centimeters to an object placed in front of the sensor, providing Terminal and LED feedback.
After the PING))) sensor receives a low-high-low start pulse from the S3’s Propeller Chip, it makes a brief ultrasonic chirping sound. Humans cannot hear this ultrasonic cound, but it is loud enough that its own ultrasonic transducer can detect when the echo comes back.
As soon as the PING))) sensor makes its chirp, it sets its output pin high. When the echo comes back, it sets the pin low. The Propeller measures how long the PING))) sensor holds this pin high. This number is the round trip time it takes for the sound to return.
The BlocklyProp Ping))) distance block contains functions that send the start pulse and measure the echo time pulse. It also utilizes functions that use the speed of sound in air to convert the echo time to a specified distance as set in the block.
Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.
Links
[1] https://learn.parallax.com/support/reference/speed-sound-air-vs-temperature