Traffic Light - advice?

I have absolutely no experience with Arduino. I have wanted to get started with Arduino for a while and I think I finally found a good project for me to do. I have an old traffic light sitting around and I want to put it in my garage with a distance sensor that senses how far away my car is. When I pull in, I want the green light to turn on. When I get close to the wall, I want the yellow light to go on. When the I should park my car, I want the red light to go on. Is this a simple enough task for a beginner to do? and if so, what electronics do I need?

Hi Zane1,

Sounds like a reasonable first project.

I'm not sure how to control the light, so you'll need to provide a little more information on that.

For the range detection part of your project, you might want to look at a PING))) sensor. You can get one from Radio Shack for a reasonable price, and they are simple to use to measure distance (i.e., lots of code online). You might also want to get a PIR (passive IR) motion detector (also from Radio Shack) to detect the approaching car before you start pinging it (also a lot of code online).

Pat.

Thanks.The lights are just normal 40 watt light bulbs. It plugs into the wall.

Zane1:
Thanks.The lights are just normal 40 watt light bulbs. It plugs into the wall.

What voltage?

130 volts

You should switch the lamps using relays, to keep the mains voltage away from your Arduino.

Mixing high voltages and low voltage electronics can be quite dangerous and the dangers are not all obvious. I recommend you stay away from that approach, and refit your traffic light with low voltage lamps that you can power through a transformer. That way your Arduino, and hence you, can never be exposed to potentially dangerous voltages. I'd approach this by using a relay shield to switch the lamps on and off.

While this seems like a good fun project, in case you're interested in different ways to tackle the problem, one that works very well for me is to tape a wood strip to the floor in front of the wheel - this means that you can feel when you have reached the right place, and the car naturally comes to a stop there.

Okay, thanks. I'll probably start this project next weekend. By the way, I currently use a tennis ball on a string that hits the windshield when I need to stop, but that's not nearly as fun.

Would a Magnecraft 107DIP-5 work? I've never worked with relays so I don't know.

Here's a link to a website selling it:

That looks like the perfect relay for this application.

Have you decided what you're going to use for distance sensors?

IR LEDs and phototransistors on the walls or ceiling with mirrors on the floor?
Pressure switches for the tires?

yes, I'll be using a passive infrared sensor to detect the motion when the garage door opens and a ping sensor to sense the distance the car is away from the wall.

Would it be much more complicated if I wanted to make this work for both cars (I have a 2 car garage)? I would just have to add another ping sensor and change the code a little right?

Using two sensors is easy enough, but if you only have one output (traffic light) then you need to figure out how to combine both distance measurements into one 'traffic light' state. Perhaps you would ignore the sensor if there is already a car in the 'parked' position when the PIR triggers? Once you have figured that logic out, just adding an extra sensor is simple.

I did a little more looking around and I found some relay shields. I'm not sure that they can handle 130 volts AC.

http://www.amazon.com/Arduino-Relay-Shield-V2-0/dp/B00BOZ7V02/ref=sr_1_fkmr0_1?s=electronics&ie=UTF8&qid=1366752915&sr=1-1-fkmr0&keywords=relay+shield+for+arduino+240+volt

Will any of these work, and if so, which one is best?

As someone who has already implemented this exact project in their garage, I can tell you that it is an easy project to accomplish. Something like the Arduino would make it even easier. Don't worry about retrofitting the voltage of the light, just use relays to switch the 120VAC to each light as necessary. My system was +24VDC but that was only because that was the operating voltage of the particular microcontroller I was using at the time (Allen Bradley). As for the sensor, use a cheap prox variant that can be had at any electronics store, think of the sensors that are in the rear bumpers of modern vehicles. For your implementation, that is all you will need. My implementation was a little more complex, but I won't go into it since it isn't applicable to your scenario. Finally, search youtube, as there is a guy who has implemented your exact design already, so you could get lots of information from that.

Let me know how it works out, I'm interested. Good luck with your project!

Jerry

Yes relays are the easy approach. See a 4-relay board like these: http://yourduino.com/sunshop2/index.php?l=product_detail&p=201

And Ultrasonic distance measuring is pretty easy. See: http://arduino-info.wikispaces.com/UltraSonicDistance

DISCLAIMER: Mentioned stuff from my own shop...

av8or1:
Don't worry about retrofitting the voltage of the light, just use relays to switch the 120VAC to each light as necessary.

The problem with that approach is that you have to consider the safety of the relay, and the high voltage wiring to it, and anything else that is mounted on the same PCB as the relay. Any project that involves high voltages and electronics in the same enclosure is potentially dangerous. Unless you're aware of all the issues and know how to address them, I wouldn't recommend that for a DIY solution. The safe approaches are to either use something like a power tail switch, where the high voltages are safely isolated from the user-supplied electronics, or convert the voltages down to safe levels. It's easy enough to get 12V lamps in any power rating you want.

I'm all for safety, so develop at your own pace and comfort level, by all means.

I haven't had a problem with my traffic light controller. I use a transformer to step down the +120VAC to +24VDC (a safe level) right at the entrance into the enclosure. I then run the controller off of that, whose outputs control the relays, whose high voltage supplies come from the +120VAC input. Each relay turns an individual light on/off. Two separate fuses are employed for safety. The enclosure is a heavy-grade industrial unit that I got off of ebay. Two fans keep things within the temperature limits specified in the controller documentation during the hot summer months.

Had the thing in my attic for over a year now, running continuously. No worries. I check on it periodically and realize that at some point I'll need to power down the unit to change out the fans due to mechanical failure from constant operation, but they're doing ok as of now.

But I digress.

Re Safety:

This relay board

See a 4-relay board like these: http://yourduino.com/sunshop2/index.php?l=product_detail&p=201

has optical isolation.

I would suggest physically locating the relay in the Traffic Light housing, providing a small 5V supply there to run the relay driver and relay coil section, and bringing Arduino +5 and the 4 (or more) Arduino output pin signals to the light. No AC or DC connection between Arduino and the Traffic Light Power.

See some examples here: http://arduino-info.wikispaces.com/ArduinoPower

DISCLAIMER: Mentioned stuff from my own shop...