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
Step 2: Wiring the Circuits
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
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
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
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.