Intro: Built-in Hackduino (Arduino) Ultrasonic Parking Guide
This is a hackduino parking guide that fits in an old work box, so it can be built into to the wall in your garage. Originally I was going to use the Arduino with the ultrasonic distance sensor to control an actual traffic light, but I decided to be a little more subtle since it turns out actual traffic lights are way bigger than I realized. This is my first instructable, and it's a work in progress, so be nice. There are a few of these parking spotters on here, this is just my personal take on it.
Distance is indicated using a single RGB LED Panel mounted to a normal blank switch plate, with a single button to set the desired distance and an ultrasonic distance sensor mounted inside an old work box located at normal outlet level.
LED will be green at >target distance + 150CM (5 Ft.)
LED gradients yellow to red from Target Distance+150CM to Target Distance
At target distance LED flashes red 5 times then goes to solid red.
After 10 seconds with no change, LED goes out and distance polling slows down for power saving.
Pressing the button and holding for 3 seconds will save the currently measured distance as the target distance.
The LED will turn blue while you're holding it, then flash green 3 times to indicate that the setting is saved to the onboard EEPROM.
Continuing to hold the button for another 3 seconds will cause the LED to turn red and the EEPROM will be written out all zeros.
LED color is based on a smoothed average that discards all raw values +/- 1 Standard Deviation from the average set.
I don't like using a whole arduino when just the ATMEGA will do, so I first built a hackduino based on this instructable with a custom pin header specifically for this project.
Arduino Sketch for this project is located at my GitHub - https://github.com/mindtesterdev/DistanceLight
Step 1: Parts List
1x Dupont Cable 200mm male to female - For hookups to pin headers
ALTERNATIVE PARTS LIST:
1x Tennis Ball
Step 2: Build Your Hackduino Board / Program Your Arduino
UPDATE: I just built another one of these using an ATTINY84. Check the GitHub page for a branch specific to that chip.
Upload the sketch from my Github to your Arduino or program your ATMEGA328P-PU using your preferred programmer with that sketch. The above video is my actual build for this instructable.
Refer to http://arduino.cc/en/Hacking/PinMapping168 for the ATMEGA Chip Pin Mapping
I followed this instructable to build the hackduino with the following exceptions:
1. I used a regular perfboard instead of the breadboard layout perfboard.
2. I included an 8-pin female header for the 4 RGB LED Pins and the 4 Distance Sensor pins.
3. I included a 6 pin header, 2 for 9V input and ground, and 2 for the points for the momentary push button. I left the middle 2 unconnected, mostly because I didn't have a 4 pin connector.
4. I included the 330 Ohm resistor between the LED cathode pin and ground directly on the board.
5. I included a 1k pull-down resistor between the pin for the target distance set button (Arduino Pin 2, ATMEGA Pin 4) and ground.
6. I did not bother to include a reset button or an onboard pin 13 LED.
The pins to connect to are below:
- Distance Sensor Trigger: Arduino: D6 / ATMEGA:12
- Distance Sensor Echo: Arduino: D3 / ATMEGA: 5
- RGB LED Red: Arduino: D11 / ATMEGA:17
- RGB LED Green: Arduino: D10 / ATMEGA:16
- RGB LED Blue: Arduino: D9 / ATMEGA:15
Step 3: Cut Out Blank Plates for Sensor, Button and LED
1. Using a sharpie, trace the cutouts of your distance sensor and panel mount button on the back of one blank plate, and the outline of your LED mount on the other. -Make sure to place the button to be mounted ABOVE the distance sensor when it's finally mounted on the wall.
2. Using a Dremel tool, carefully cut out the mounting holes using the outlines from above. Check fitment as you go.
3. I mounted the Distance sensor by stacking 2 rubber O-Rings directly around the emitter/receivers as spacers to account for the height of the clock on the front of the board, then pushed them through the holes that I cut, and then added one more O-ring to hold it in place. Make sure the pins point down so they don't get in the way of mounting the button.
4. When mounting the LED in the holder, the holder I used only had a backing for a single cathode / anode pair, so I just put the RGB LED in and filled it with hot glue instead.
5. You could use spade connectors to attach hookup wire to your button for the jumpers to the board, but I didn't have any so I just soldered to the terminals
Step 4: Make Your Riser Wire / Power Supply
The LED is mounted in a separate box 3-5 feet above the box with the sensor and your board.
- You'll need 4 wires for the LED to run up inside the wall from one box to the other. Make sure to measure the distance you want between the boxes, then add plenty of wire for slack inside the wall. I used Cat6 since I've got a lot laying around; I just twisted the pairs together and used each pair as one wire This is probably overkill. On one side I soldered the female connectors from 4 strands of the dupont cable, and on the other I just soldered some hookup wire with a stripped / tinned end to plug into the board.
- For power, I just hacked the barrel connector off the end of the AC/DC adapter and soldered on some hookup wire so I could plug directly in to the pin header on the board. Alternatively, you could just put a barrel jack on your board, or use the existing one if you're using a full Arduino Uno.
Step 5: Connect It All Together and Test
At this point it's probably a good idea to put everything together and power it up to test it on the bench. Be sure to hold the button down for the full 6 seconds or so until it turns red to clear the EEPROM the first time you power it up. This is important especially if you started with an un-bootloaded ATMEGA chip. I believe the EEPROM that ships may have random bits on it, rather than all 0s because I got some strange results when I didn't do this. Finally, set the distance with the button by holding it until the light flashes green 3 times using one hand in front of the sensor to set a distance. Once it's set verify that the LED changes color based on the distance your hand is away. Assuming everything works, we can move on to jamming this whole thing into the wall.
Step 6: Install It All in the Wall
At this point it can all be installed in the wall of your garage. A lot will depend on your power availability as to how you install it, and how to install an old work box is outside the scope of this article. I was lucky enough to have a power outlet pretty much dead center of my car in the garage, so I just added an old work box right next to it.
DO THE FOLLOWING AT YOUR OWN RISK, AND MAKE SURE YOU TURN OFF THE CIRCUIT BREAKER TO THE OUTLET FIRST!
I spliced 10 AWG electrical cable on the Neutral and Hot lines inside the outlet, and pulled it out into the wall. I connected those leads with wire nuts directly to lines soldered to the prongs on the AC/DC adapter and shoved it inside of the wall, then brought the DC side through one of the bottom wiring holes on the back of the old work box.
When you install the top box, you're probably going to want to use a laser level to match the sides of the LED box at the top with the box at outlet level so that one is directly above the other. Before tightening either box in, run the riser cable down the wall, connect everything, and make sure you've got your colors connected correctly for the RGB LED. If, like mine, your wall is full of insulation, you'll need to use fish tape to get the wire through the wall between the boxes.
Step 7: Test Again
Once everything is buttoned up set your distance and test again.
The video above is my actual test.
The expected behavior is:
- Green light at > 5ft away from your target distance;
- A distance based gradient color change from 5 feet out from your mark from yellow -> orange -> red;
- 5 red flashes when you hit your mark.
Its way easier to see than my video lets on.
mindtesterdev made it!