Free of Tennis Balls
When we moved into our new house we upgraded to a bigger garage than we had before. My wife now parks in the garage, something she did not do before. Her main problem is not knowing how far forward to pull the car in and leave enough room in front of, and behind the car. Instead of the traditional tennis ball hanging from a string, I decided to take a more hobbyist approach to the problem at the risk of negatively impacting tennis ball sales.
Although this type of project has been done several ways I wanted to take my own approach and simplify the code and hardware while making it easy to adjust and personalize for your own use. By default all measurements are in inches, although you could easily use centimeters since that information is available as well. All you would need to do is replace all instances of inches in the main loop with cm. If you’re using a laptop to debug distance you will need to uncomment the debug line that displays cm and comment the one that displays inches. Finally, you will need to change the constants for each zone since they are specified in inches.
The range of the PING))) sensor (#28015) is ~0.8 inches up to 3.3 yards and is split up into four zones labeled Zone1 through Zone4. Please see picture for a map of the zones. The values in the constants section for each zone are inches from the sensor/wall.
Zone 1 (Striped) is closest to the sensor / wall and indicates the area you don’t want to occupy. When you are in this zone the Red LED will flash on / off to indicate you are too close. In our garage this area is big since we want to be able to come around the front of the car with plenty of room. The default setting for Zone 1 is 36 inches (3 feet).
Zone 2 (Red) is the area where you want the front of the car to stop in. This will be between the Zone 1 and Zone 2 settings. When you are in this zone the Red LED will be on solid telling you to stop since you are in the desired zone. You don’t want to make this zone too small since you will need to stop within it without having to keep adjusting. You also don’t want to make it too big. The default setting is 46 inches giving you a 12 inch buffer. When you set this you want to make sure this is as far back away from the wall as you want to be as well. In our garage if we are closer to the Zone 2 mark the back of our car still has about 12 inches of clearance from the overhead door.
Zone 3 (Yellow) is the area you set where you want to slow down and be prepared to stop. When you are in this zone the Yellow LED will be on letting you know you are approaching the Red zone. The default setting for this zone is 80 inches and works well for our garage and the speed that my wife enters it. You will of course want to tune all of these values to what works for you.
Zone 4 (Green) is the area from where the PING))) sensor first detects the car until where you enter the Yellow zone. When you are in this zone the Green LED will be on. By default this value should be the maximum range detected by your PING))) when no car is in the garage. This is the zone where you can pull in normally.
Have Laptop Will Travel
While not required, a laptop is a great help in getting everything where you want because while the code is running it is displaying the values it sees on the DEBUG screen and you can note these positions when setting your Zone constants. You will definitely want to know what the maximum value your PING))) sensor reports when no car is in the garage and you’ll want to make sure that value is stable and set the Zone 4 constant to this value.
Protecting Your Assets
The PING))) sensor isn’t really well protected against environmental effects and I didn’t want someone or something to accidentally brush against it and damage it, so I obtained a small protective enclosure from RadioShack to house the module.
The sensor enclosure is shown milled in the first photo above. The second photo above shows the PING))) sensor mounted to the cover lid using nylon spacers. The nylon spacers prevent damaging and shorting traces on the PING))) sensor which can happen when using metal screws, nuts or standoffs. Notice also that the header pins have been bent back slightly to allow the cable to connect inside the enclosure.
I mounted the enclosure to the wall using drywall screws. The ideal position of the enclosure is such that the PING))) sensor can easily see the front of the car. In our case this meant lining the sensor up with the license plate. Any higher or lower and the curvature of the car could cause reflection away from the sensor.
As in many of my previous projects, this one was built on a Super Carrier Board (#27130). This inexpensive project board is ideal for one-off BASIC Stamp finished projects because it contains most of what the Board of Education does, except that it is intended for soldering and runs the BASIC Stamp Module from the on-board regulator allowing a wider range of supply voltages. The enclosures that the PING))) and Super Carrier Board were mounted in were just plastic prototyping enclosures I had in my parts cabinets. You can refer to the Bill of Materials for the sources of the ones I used, although any enclosure which will fit these boards in will work. Optionally you can mount both the Super Carrier Board and the PING))) right to the wall, although you may want to cut the Power LED trace on the Super Carrier Board to prevent it from giving you a false GO signal. You could also remove the Green power LED from the board by desoldering it.
As you can see in the photo I used 10 mm LEDs in this project since they’re much easier to see. The header for the PING))) sensor is mounted at the bottom aiming down. Please note that the schematic shows that there are 220 ohm current limiting resistors for the Green/Yellow LEDs while the Red has a 470 ohm resistor. This is because the Red LED requires less current to obtain the same light intensity. So to make the LEDs uniform I used these values. Different LEDs have different forward voltages and currents so you may need to adjust these values depending on the LEDs you use. Often 220 ohm through 470 ohm resistors will work for most LEDs. You may notice in the photos that I used 1/4 inch plastic spacers to keep the LEDs at the same height from the PCB. This also allows the LEDs to extend through the face of the enclosure. Next the Super Carrier Board has been mounted inside the enclosure using standoffs and a hole was cut into the bottom of the enclosure for the sensor lead. Finally, holes have been milled in the face of the enclosure for the LEDs.
Now that everything is assembled and mounted we can use our laptop computer to make adjustments to the code as necessary. You can see that power was obtained from a 7.5V wall adapter plugged into an outlet in the garage. You can load the Garage Parking Assistant V1.0 code into the control board to get started. Now pulling into the garage is as easy as pulling up to a traffic light!
No Laptop? No Problem!
Let’s explore how we can improve this project. I realize some readers may not have a laptop they can take out to the garage to help tune their garage parking assistant, so the first modification we’re going to make to improve the Garage Parking Assistant is to add a button that will allow us to set all of our zones without a PC handy.
To do this we’ll first modify the face of the main enclosure to add a hole for the push button switch as shown.
Then we will install the switch and wire as shown.
The next step is to remove our control board and add a header for the switch wire to plug into. This was done by adding a right-angle (RA) SIP header to the Super Carrier Board as shown. A 10K pull-up resistor was added, as was a 220 ohm series resistor.
Like Ringing A Doorbell
The source code was revised for the hardware changes and the new version (V1.1) can be loaded into the control board. Now you can set up zones by holding the button down for approximately two seconds until all three LEDs flash three times. At this point the Green LED starts flashing. The unit is waiting for the Zone 4 setting. For most applications this will be the maximum range of the sensor, so with nothing obstructing the sensor you can simply press the button to set maximum range. The sensor should not be able to see the garage door when closed. Once you press the button to set the Zone 4 range the Yellow LED starts flashing waiting for you to set the Zone 3 distance. Pull your car in to the point where you would want to slow down. Once in position press the button again. The Zone 3 distance is now set and the Red LED starts flashing. The unit is now waiting for Zone 2 where you would normally stop. Pull you vehicle into position taking care to make sure you have exactly the clearance you want and press the button.
The Garage Parking Assistant is now ready to use the new values for parking. Zone one is set automatically based on a buffer and minimum allowed distance of 6 inches. So pulling ahead of the Red Zone will still cause the Red LED to flash warning you to back up. Take care and have fun! Both versions of the source code are attached below.