Intro: Arduino Distance Meter
This a project I've been working for some time now. It is a device that shows in a little LCD display the distance to the nearest object it can find, usually the floor, the ceilling and two walls or columns. So it can be so helpful to hang a picture, a shell, a light point, calculate the area of the entire wall, etc.
You can find the code here
If you are in your phone or tablet and you can't see the video, click here
I have chosen to use cheap materials cause I don't really need a high precision and like almost always I am doing it for fun... so I think you can buy all the electronics for less than 15$ on ebay:
1 Arduino Mega
4 Ultra-sonic sensor sr04
1 LCD 16x02 Display
1 Perfored Prototype board
2 10k Resistors
1 10k Potentiometer
Male and female arduino pin header connectors
A few cables
A little bit of hard plywood, of course
The sr04 has a 3mm resolution, so I am only using it in entire centimeters. You can also change it to inches pressing a button but then the resolution is even worse. I am trying to figure out how to get a better resolution, I know it is possible. Needless to say any help will be apreciated.
It has 4 programs:
Measures the distance from up, down, left and right to the hole, the center of the device.
When you chose the second program, all the measurements reset to 0 and it will start measuring from that point. In this case I am making a mark 10 centimeters away from the first one.
The number 3 does not measure from the hole but from the opposite side of the device. Useful if you want to know, for example, the distance from 2 walls or the height of the ceilling.
The last one calculates the area. If you place it in a corner it will show you the total area of the wall, in this case the number you can see on the right.
Step 1: Making the Case
You can start cutting the plywood. If you have a different idea for the design of the box, you can avoid this part and go directly to the electronics. Tilt the disk 45 degrees and cut the four pieces for the frame.
Drill the holes for the sensors and for the usb cable and use a chisel adapt the place for the connector. You can use a little bit of fabric to make sure they fit exactly in the middle and mark with the drill.
Ready to apply the glue. Remove the remains of glue and check if it is squared.
Step 2: Top and Base
Cut the base and cover and use the hand plane if needed. Mark and drill the holes for the buttons, the screws and the bubble, wich is recycled from a cheap spirit level.
Make the hole for the display. Glue and screw a little block of plywood to hold the steel pipe.
Step 3: Varnish
We can apply now the varnish, 3 coats of nitrocellulose lacquer in my case, and between them you can use transfer paper to write the names of the buttons.
Step 4: Electronics
Following the schematic, I have used a bread board to make sure all the stuff worked before I soldered all the componets. Connect it to the computer and upload the code you can find in the intro, check all is working ok and you can start the assembly.
With a perforated board I made a shield for the arduino with a little circuit. You can actually do it without it but this way it will save us a lot of wires and the result will be cleaner.
To make it lower in order to fit in the case I moved the plastic part of the pins to the end and soldered them from below.
To connect the display I had used a female pin header connector like this one.
You'll probably have to solder the pins of the display depending on where you bought it.
This female connectors can be so useful if you don't want to solder the sensors.
Solder the potentiometer, the resistors and the rest of the cables and you can finish assembling it.
Step 5: Assembling
With a little plastic pipe you can make these little spacers. Now asembly the buttons and the level.
I didn't have screws as small as the holes of the ultrasonic sensor so I had to use a drill to make the holes bigger. Take care if you have to do the same, I think a 2mm drill could be the bigger one you can use if you don't want to brake something.
Assembly the arduino with the board and the display and all the wires following the schematic.
Bend a little plate and screw it to the base to hold the battery. You can use a little piece of EVA to avoid scratching the base or the wall.