# Arduino controlling separate traffic light

I have an arduino that can turn on 3 LED's separately. I also have this traffic light (12v with 3 plain-old lightbulbs) that, when plugged into an outlet, turns on all of the lights.

What could I use to "gate" the power to the traffic light using the arduino? I'd like for the two devices to remain on their separate power supplies.

Looking for some kind of connectors to solder between each of the three lightbulbs that I can gate using simple currents from the arduino. Any ideas? (I'm obviously a novice, so any help is appreciated!)

-
 How much current does each bulb need, at 12 V? – Telaclavo May 27 '12 at 1:42 The bulbs are at 75W, so I'd probably need 12 amps? 5 amps if I put in 60W's – ABC May 27 '12 at 2:48 Ok, then you need devices with higher current ratings. Now it is too late here. Tomorrow I'll look for you some other parts. – Telaclavo May 27 '12 at 2:56 Oh I get it now.. I was supposed to do the Ohm's law calc with the arduino voltage, huh? when I do 60W/75W with 5V, I get 12A/15A.. – ABC May 27 '12 at 3:16 @tester - No, if it's a 12V bulb you'll have to supply 12V, even if the Arduino does 5V. A transistor or MOSFET will allow you to switch 12V with a 5V signal. See my answer. – stevenvh May 27 '12 at 12:14

75W @ 12V is 6.25A per lamp. We'll have to use some kind of switch in series with the lamp to control on/off.

Edit
There seems to be some confusion about the voltages involved. It's not because the output voltage of the Arduino is 5V that this will also be the voltage for the lamp. All three of my solutions allow a lower voltage to switch a higher one. So your Arduino is perfectly able to control 12V, or even 230V AC, but then you need a relay.

relay
This would have an advantage the following solutions don't have: it can switch AC as well as DC. You don't say in your question which one the 12V is. Relays have another advantage: they have a low on-resistance, and therefore dissipate little power.
They have disadvantages too. Especially switching incandescent bulbs is tricky: the high inrush current because of the cold filament could weld the contacts. And because they're mechanical devices they have a limited lifetime, for power relays often between 10 000 and 50 000 cycles.
If your 12V is DC you can use that voltage to power the relay, if it's AC you'll probably have to use a 5V relay, depending on what you have available. More about controlling the relay further on.
This relay is rated at 16A, and 80A inrush current.

BJT (Bipolar Junction Transistor)
A transistor amplifies a small input current to a large output current. The ratio between the two is known as the transistor's $H_{FE}$. For power transistors $H_{FE}$ isn't very high, usually around 30, so to get 6A for your lamp you'd have to input 200mA. Your microcontroller can't supply that. The solution is to use another transistor to amplify the few mA from the microcontroller to the 200mA. The cascade of transistors is called a Darlington, and because their amplification is the product of both transistors' $H_{FE}$ the combined $H_{FE}$ can be high, sometimes higher than 1000. A 6A lamp current could be switched with only 10mA base current, which most microcontrollers can easily supply.

A Darlington has a big disadvantage: it has a rather large voltage drop, known as $V_{CE(SAT)}$ when switched on. Less than 1.5V is rare. That means that at 6A it will dissipate 10W, and that's absolutely not what we want.

While we're at the transistor, we'll also need one to drive the relay. Not only because the microcontroller probably can't supply the required current for it, but also because its output can't stand the 12V supply it would see when off. The schematic shows a transistor controlling a relay, replace relay by lamp for your traffic light.
The relay doesn't require as much current as the lamps, and we won't need a Darlington here. The relay I referred to needs only 35mA in the 12V version, if you use a BC817 you'll need less than 1mA to switch the relay on. Use a 2k2$\Omega$ for $R_B$, $R$ isn't needed.
What is needed is the diode over the relay. A relay is inductive, and when you switch inductive loads off they may cause a very high voltage over the transistor, which may damage it (read: destroy). The diode deviates the high voltage to the power supply, so that it can't do any harm. The type is not very critical, but often a Schottky diode is chosen, because it's fast, and the low voltage drop limits the dissipation. A BAT54 will do fine.

MOSFET
The schematic for the MOSFET looks very much like the transistor's:

A BJT is current controlled, but a MOSFET is voltage controlled. For a BJT, it's the input current which defines the output current, remember the amplification factor $H_{FE}$. A MOSFET can be controlled by applying a voltage to the gate, there will be almost zero current. A logic-level MOSFET can be switched directly by a microcontroller. We'll just have to find one which can handle the large current. This one looks nice. It will drive tens of amperes at a 5V gate voltage, and have an $R_{DS(ON)}$ of only 10m$\Omega$. The $R_{DS(ON)}$ is for the MOSFET what $V_{CE(SAT)}$ is for the transistor: it determines the device's power dissipation. (6.25A)$^2$ $\times$ 10m$\Omega$ is only 400mW. Compare to the 10W of the transistor and you know why MOSFETs are preferred to switch high currents.

The schematic shows two resistors, $R_{IN}$ and $R_{GS}$. The function of $R_{IN}$ is to limit the current to charge /discharge the gate capacitance when switching. It's a very short current peak, not even high, but many logic ICs don't like it. You can use a 1k$\Omega$ to 10k$\Omega$ for this, the value is not very critical in your application. $R_{GS}$ pulls the gate to ground if there's no $V_{IN}$ connection. MOSFET gates should not remain floating. A 1M$\Omega$ resistor is OK here.

-
The schematic for the MOSFET case will make the OP think he needs $R_{IN}$ and $R_{GS}$, which is not the case. // "But a transistor is current-controlled, a MOSFET voltage-controlled" ? You said in another answer that you know you are a good communicator. – Telaclavo May 27 '12 at 12:50
@Telaclavo - Uh-oh, this is gonna chase me for the rest of my life! :-) I'll fix the resistors, and explain the difference transistor/FET a bit more. Thanks for pointing these out. – stevenvh May 27 '12 at 12:56
@stevenvh, I would just suggest it becomes, "or even 230VAC with the relay." He did make a mistake as a hobbyist, it is going to happen. A large part of it is that you and Telaclavo shared one solution so he picked the "agreed upon" answer. Users have reacted so aggressively on the other question that he requested a delete of it due to embarrassment. This is another case where I wish users had realized the user was not a complete idiot and just very new and had approached it a big kinder. That was not you though, yours was pretty clear. – Kortuk Jun 14 '12 at 13:17
@stevenvh, When i was really young I had someone tell me the reason wires had plastic was to insulate the electricity from getting out. So I took a little wire with insulation for maybe 48V and put in in an outlet... It hurt a lot. We all learn somehow, and my brain will never be the same. – Kortuk Jun 14 '12 at 13:27
@Telaclavo, What do you mean by the statement, "You said in another answer that you know you are a good communicator." ? How is that helpful and not rude? – Kortuk Jun 14 '12 at 13:28

For each light bulb, you can use a circuit like this:

D1 = MBRF1035CT. You can buy it here. You only need it if you have long wires between the bulb and the MOSFET. The diode should always as close as possible to the MOSFET and to the +12 V supply. Best is to place everything (Arduino and MOSFETs) close to the traffic light box.

T1 = IRLU8726PBF. You can buy it here. With this device, and your 6.25 A, you don't need any heatsink.

Both choices have good specs/money ratio.

"GPIO OUT" = Any general-purpose (digital) input/output configured as totem-pole output (not open drain). You don't need any resistor at the gate of the MOSFET.

And, of course, program your Arduino so that it can control each one of those three digital outputs as desired.

-
Okay, so 3 T1's, one for each GPIO I have. GPIO -> T1 cold, T1 hot -> bulb, and T1 ground -> the frame of the stoplight? – ABC May 27 '12 at 2:32
also, do you know of a place where I can order a few of these? element 14 wants me to buy 150! lol – ABC May 27 '12 at 2:51
@tester "T1 cold" and "T1 hot" mean nothing. Look at the datasheet of T1, to know where it has its gate, drain and source, in the physical device. In the schematic, gate is to the left, drain is on top, and source is at the bottom. So, GPIO goes to gate, source goes to ground, and drain goes to one of the two nodes of that light bulb. – Telaclavo May 27 '12 at 2:53
@Telaclavo - Surely the diode will only protect us from the inductance of the long wires if it is also connected with long wires. Otherwise it only protects from the inductance of the bulb. – Rocketmagnet May 27 '12 at 10:00
It might be worth noting that this solution is not okay for a 120V bulb. This might have caused the OP to believe it was okay for higher voltages such as 120VAC. (cc @ABC) This only really being good for DC. – Kortuk Jun 14 '12 at 13:07