Introduction: Pocket Distance Scanner
This pocket-sized device is designed to be used as a measuring tool when you either don't have a measuring tape or when using one would be impractical or impossible. It uses an ultrasonic sensor and Arduino Nano to determine distance and display it on an LCD display. This model is designed to power up when opened and turn off when closed. While reading the LCD screen the sensor is on the other side of the device, so you can point the device at the target like a camera. Also, there are a few situations where I chose to use a less-than-ideal construction method (tape, etc.) in order to allow a person building this to be able to take it all apart and reuse the iPod case.
Arduino Nano or smaller
4-pin ultrasonic sensor
Parallax 2x16 (or other) LCD screen
Wires, jumper wires
Push-to-break (normally closed) button switch
Very small breadboard
9V battery plug
Zip tie (or something similar; basically something long and thin)
Motor terminal connector (or something similar; basically something small and short)
Pocket-sized container - I used an iPod touch 4 case; if you use an iPod 5 case the components will probably fit inside better
Step 1: Wire the LCD Screen
For this project I used an iPod touch 4 case that they're sold in, and since the Parallax LCD screen is less than a millimeter too high, I connected the wires as shown in the picture. By wrapping the wires tightly around the pins and spacing them out with the insulated wire you can plug it in to the breadboard (and fit it inside the iPod case) without using jumper wires.
Step 2: Wiring the Circuits
Assemble the circuit in the diagram (but with a 9 volt battery instead of 2 AAs [this was my first time making something with Fritzing!]). Also, in order to make the device power up when opened, you need to use a normally-closed switch.
As far as the breadboard goes, I got mine from an electronics kit. It 10x5 plugs and is smaller than the Arduino Nano. If you're going to be using an iPod case, I'd recommend either using one very similar in size or none at all. If you manage to find one like this and you're using jumper wires, try to put as many of them on one side as possible, to save space.
Step 3: Program the Arduino
You will need to download the Arduino library for the ultrasonic sensor if you haven't already - click through this page to get it:
Then paste this into the Arduino IDE and download it to the Arduino:
#define TRIGGER_PIN 11
#define ECHO_PIN 10
#define MAX_DISTANCE 500 // Maximum distance (in centimeters).
//Maximum sensor distance is rated at 400-500cm.
const int TxPin = 1;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);
DistanceIn = sonar.ping_in();
Serial.print(DistanceIn); // Convert ping time to distance and print result
// (0 = outside set distance range, no ping echo)
Serial.print(" in ");
//By enabling this section you can display the distance in centimeters.
DistanceCm = sonar.ping_cm();
Serial.println(" cm"); */
Step 4: Fit It All Inside
After a few hours of experimenting the setup below is theonly wayI could find to fit everything inside the iPod 4 case. As I said earlier, if you use a bigger case, even an iPod 5 case, the layout could be different. Or, if you find another way that works, great! In this case, though, there are several things to take into consideration:
The LCD screen should be one of the first things in - keep it as far towards the back (the hinged side) as possible while still leaving room for wires.
Place the ultrasonic sensor at the front of the case with the jumper wires running to the back of the case.
If you use a small breadboard, put it in last so you can get to the wires before and after assembly.
Place the switch on top of the other components so that it is depressed when the cover is closed.
Secure all the components with electrical/duct/clear tape when putting them in, then with additional bands over the top to secure wires and loose parts. You may not want to secure the battery as much if you're going to use it often.
Step 5: Construct a Latch
This is a simple homemade latch you can use to keep the case closed. If you have a better one I'd recommend using that instead, but if you don't then this works well enough. Basically you just tape the small object you chose (like a motor terminal connector) to the top or bottom and then tape the longer thin object (like a zip tie) in a loop to the other side in such a way that you can press down on the case to pull the loop off the "hook" - you want the case to be slightly open by default.
Also, my iPod case still had some tape from when I got it that worked well for a hinge, but you can add tape or another type of hinge too.
Step 6: Usage Notes
This "scanner" can measure up to about 10 feet, but I've only tested it at 7 feet and less. After opening the cover, hold the device with the ultrasonic sensor facing the object you want to measure to. Since the program is outputting the distance measurement to the serial port, which is usually to a computer, the measurements will be shown while scrolling across the screen (they stop when the measurement is constant for a few seconds). By using the Parallax LCD library you can change the program and what the display shows, but it never worked when I added the library on my computer. It's probably just something with my program.
We have a be nice policy.
Please be positive and constructive.