Here’s the source code for the Arduino + PING))) + 7-Segment Shield ultrasonic distance sensor project I build for this video. It is the progenitor of my Arduino Nerf sentry gun code, which I’ll be posting soon. Warning: my code gets the job done, but isn’t elegant.
In the Maker Shed![]()



Going through the parts bins at the local Radio Shack, I see this PING sensor is for sale.
@John, on your code.
NICE commenting. You cleared up many mysteries for me. I am a cut-and-paste hack who is learning the language.
Thanks Volkemon, I’m glad it’s helpful. What I lack in code efficiency I try to make up for in clear comments!
How would you use this to measure a package LxWxH.
How would you use this to measure a package LxWxH and take all the measurements at once ?
Hi Danny, great question. Here’s one way that comes to mind: use three sensors arrayed in X, Y, and Z (or L, W, and H) directions, put the sensor inside the package with a delay of a few seconds before it takes the reading. Close the package, wait, then open it up. You’d need to add something to the code to cycle between the three readings, and maybe display the volume calculation. It would also need to stop trying to take continuous readings. Anyone have other ideas?
hi John, first of all, thanks for your work.
But, I have a question for you.
I’m from Barcelona and as you know in europe usually the distances are in centimeters or meters.
Are there any easy way to change inches for centimeters?
I don’t have any experience in programming .
any idea?
thanks a lot in advance and congrats for the post
Hi there. The code is already in there for figuring centimeters. It’s being printed to your serial terminal display, just not to the 7-segment display (and I’m doing all the averaging, etc. on inches). You should be able to convert it to using the cm pretty easily.
There are a couple of places where I display “in.” which you could change to “cm”, too.
Best of luck!
-John
Hey, whatever happened to you posting the code for the Nerf Vulcan Sentry Gun?
// What's Trending
Raspberry Pi Design Contest
Maker Faire: Day One
Maker Faire: Day Two
Seventeen Sneaky Secret Hides
10 Things to Connect to Your Raspberry Pi
A Photo Tour of Maker Faire
Arduino Announces New Wireless Linux Board
The Road to the I/O Sensor Network
// What's Shared
A better way to slice a pumpkin
DIY Nerf Darts
In the Maker Shed: Minty Boost USB Charger
100 Dollar Store Organization Ideas for Craft Rooms and Beyond
Mad’s Mouse House
Lace Princess Crowns
I Have a (Puzzling) Dream
Play the Rings of a Tree Trunk Like a Record
// Most Commented
DIY Hacks & How To’s: Get Emergency Power from a Phone Line
Resin Casting: Going from CAD to Engineering-Grade Plastic Parts
Ten Tips for Screws and Screwdrivers
Ten Tips for Better Measurement
Makers on TV: Big Brain Theory
Arduino Announces New Wireless Linux Board
Tool Review: BioLite CampStove
Pitches with Prototypes: Solar Tracker
Trending Topics
Get our Newsletters
About Maker Media
Subscribe
to MAKE!
Get the print and digital versions when you subscribe