loading

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 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.

Neat little Instructable! One thought you might try an ATtiny85 for the main chip. you don't need all the inputs and power of the larger chip. The tiny will also take a boot loader and has a built in crystal so you can save some solder time and overall cost.
<p>Thanks, maybe on the next one. I'm not that familiar with the ATTINY's pinout, I need 3 normal digital I/O pins for the distance sensor and button, and 3 PWM for the RGB LED. What's the internal clock speed? 8Mhz, like the 328?</p>
Darn! I was mistaken. The attiny85 is one short in two ways. it only has five input/output pins. it also only has 2 pwm pins so I guess I blew that one.
oh.. and you asked about speed. it has the following:<br><br>ATtiny25V/45V/85V: 0 &ndash; 4 MHz @ 1.8 - 5.5V, 0 - 10 MHz @ 2.7 - 5.5V<br><br>ATtiny25/45/85: 0 &ndash; 10 MHz @ 2.7 - 5.5V, 0 - 20 MHz @ 4.5 - 5.5V
<p>So I'm sure you're not following this thread anymore, but I did just build one of these for my mother and wound up using the ATTINY84.</p>
<p>Hi, I followed you instructable and very pleased with it, Have you got the circuit diagram for the ATtiny 84 version that you have made. have you thought about doing another instuctable on building this version and how to program the ATtiny. Regards Bill</p>
<p>Hi Bill! I'm glad you like it! Can you post pictures of your install? Did you use an off the shelf Arduino/clone, or did you build the hackduino? Unfortunately, there's not a circuit diagram for the ATTINY84 version, but the pinout is defined in the ATTINY84 branch on my github in the ino file. I've pasted the link and pinout below. As far as programming the ATTINY, I used my bench Arduino Uno / breadboard setup with the Arduino as ISP program as the programmer. There are a bunch of tutorials online, including here on Instructables as to how to do it. If you have a question about it, I'd be happy to answer it here. I use this diagram as a reference for the ATTINY to Arduino pinout: </p><p><img src="http://rc-master.ucoz.ru/Arduino/Pinout/attiny.jpg"></p><p><br> <a href="https://github.com/mindtesterdev/DistanceLight/blob/ATTINY84/Distance_Light/Distance_Light.ino">https://github.com/mindtesterdev/DistanceLight/blo...</a></p><table><tbody><tr><td>#define trigPin 1</td></tr><tr><td>#define buttonPin 0</td></tr><tr><td>#define echoPin 2</td></tr><tr><td>#define red 7</td></tr><tr><td>#define green 6 </td></tr><tr><td>#define blue 8</td></tr></tbody></table>
Definitely could be useful for smaller projects. I thought there was a chip between the 8 pin tiny and the 28 pin mega, like a 16 pin, but I couldn't find it just now. I just used the mega because I had a 10 pack.
Instead of doing 5 flashes, you could just do quick flashing when you're at your mark.
<p>That's true, but I didn't want a distracting flashing red light in my garage all the time any time you walked by the sensor. I just wanted a demarcation because the yellow to red gradient is basically red just before you hit the mark. </p>
<p>Weird, the comments from last night disappeared...</p>

About This Instructable

12,431views

200favorites

License:

Bio: I'm a software developer and DBA by trade, just digging into electronics for the first time. I'm also a private pilot and skill ... More »
More by mindtesterdev:HumidorPi: A Smart Humidor On The Cheap with Raspberry Pi and Node-RED Built-in Hackduino (Arduino) Ultrasonic Parking Guide 
Add instructable to: