Garage Parking Light

This is a project I'd been thinking about for some time, but was too lazy to do. Finally a version came out in Nuts & Volts, January 2010. Their version was based upon a Parallax Basic Stamp module. Not a huge problem: I translated it for Arduino and built the whole thing on a small circuit board. This project is also well documented over on Savage Circuits. I have nothing against the Basic Stamp modules, it's just that I had parts on hand to build an Arduino version.


The Parts List is similar to the magazine defined project.

1Project Enclosure, approximately 3" x 2" x 1"AnywhereFor the Sensor
1Project Enclosure, approximately 5" x 3" x 1.5"AnywhereFor the Controller & LEDs
1PerfBoard to fit the Larger BoxAnywhere 
110mm Red LED Red is brighter; use a larger resistor
110mm Yellow LED  
110mm Green LED  
1PING))) Ultrasonic SensorRadio Shack 
1470 ohm, 1/4W ResistorAnywhereRed LED is Brighter
2220 ohm, 1/4W ResistorAnywhere 
1Minimal Arduino or RBBB Kit Kit or build a Minimal Version from parts

Arduino Code

The original Basic code for the Stamp was translated to Arduino Processing (essentially C++). I've retained the original author's comments and I've used the constants provided therein for evaluating distances to the arriving car. I didn't provide the "Setup" mechanism, including the momentary press button, but I've included it in the translated code. I used the original vehicle distances, as they suited my needs.

The Arduino platform used can be whatever is on hand. I usually use an RBBB from Modern Device, but in this case, I used a minimal Arduino built from a couple of resistors, a resonator for clock (or a crystal if you have one). The minimal Arduino, and a programming header was constructed on the same board as the LEDs are placed, but off to the side.

One feature I did add was a 'darkness' sensor — I didn't feel that the PING))) Ultrasonic Sensor should be working when it's not needed, so I sense darkness with a simple analog read of the voltage drop across a Cadmium Sulfide (CdS) resistor. Since the garage is dark except for:

  • Daylight - bright light enters from the open garage door
  • Night - headlamps will turn the Parking Light on

		  if ( analogRead(LightSensor) > 600 ) {
			// Lights are on, or door is open and it's daylight.. Start to Work...
			// establish variables for duration of the ping, 
			// and the distance result in inches and centimeters:
			long duration, inches, cm;
			: (rest of PING Loop here...)
		  else { 
			// DARK! Sleep Now...
			digitalWrite(RedLED, LOW);
			digitalWrite(YellowLED, LOW);
			digitalWrite(GreenLED, LOW);

The CdS sensor peeks through the enclosure via a small hole above and to the left of the LEDs.

Hardware Differences

Since the controller changes from a Basic Stamp to an Arduino, there are a few hardware changes. The Arduino Digital and Analog Pins selected are:

  • Ping Pin - In/Out, Digital Pin 8; uses the PulseIn Function to detect the reflected Ping
  • Red, Yellow and Green LED Driving Transistor Bases: Digital Pins 11, 10 and 9
  • Program Button (implemented in code, but not used): Digital Pin 12
  • CdS Voltage Sensor: Analog Pin 5 --> inputs from a voltage dividor including the CdS sensor

The original article uses the Basic Stamp to drive the LEDs directly. I used a transistor to drive them, as the Arduino pins cannot source about 40ma of current. The Digital Pins might be able to supply enough current, but I've used the pin to drive the transistor base and let the transistor switch the current as a conservative design choice.

Source Sketch Files

  • Version 1 - works with Arduino-0018, uses a CdS light to turn off when garage is dark.