Garage Sensor Head Unit with Green, Amber, and Red LEDs

Garage Parking Light

I really liked the Nuts & Volts Magazine project “Garage Parking Assistant” in January 2010, but I don’t ‘do’ Basic Stamp – no reason really, just not my favored platform and N& N & V seems to base a lot of projects on that platform.

So, I translated it to Arduino and replaced the Basic Stamp with a minimalist Arduino (Atmega 168, a clock resonator, a couple of resistors and capacitors, and an LM7805 voltage regulator). From there, code translation (BASIC to  “C++”) was easy. I make no originality claims and I’ve only provided a code translation.

Garage Parking Light – Translation to Arduino

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.

Parts

The Parts List is similar to the magazine defined project.

Qty Description Source Notes
1 Project Enclosure, approximately 3″ x 2″ x 1″ Anywhere For the Sensor
1 Project Enclosure, approximately 5″ x 3″ x 1.5″ Anywhere For the Controller & LEDs
1 PerfBoard to fit the Larger Box Anywhere
1 10mm Red LED Red is brighter; use a larger resistor
1 10mm Yellow LED
1 10mm Green LED
1 PING))) Ultrasonic Sensor Radio Shack
1 470 ohm, 1/4W Resistor Anywhere Red LED is Brighter
2 220 ohm, 1/4W Resistor Anywhere
1 Minimal Arduino or RBBB Kit www.moderndevice.com RBBB Kit or build a Minimal Version from parts

Arduino Code

The original Basic code for the Stamp was translated to Arduino’s familiar  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

PING Ultrasonic Sensor
PING))) Ultrasonic Sensor, mounted on the wall at bumper height.

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);
	delay(1000);
}

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.

Leave a Reply

Your email address will not be published. Required fields are marked *