Transistor question

Hey all,
I am trying to light a string of LEDs in a row using a transistor and my Diecimila. I have 6 LEDs using 2 forward volts a 1ohm resistor and a NPN 2n4401 transistor. I have the LEDs hooked up to an external DC power supply and the Diecimila hooked up to my laptop's USB. Does the Diecimila have to be in the same circuit to work? If not and this configuration is fine what do I need to get the transistor to switch?

The arduino needs to share "Ground" with your transistor/supply, like in the following picture:

Thank you westfw. If I were to hook my Arduino to the external power supply do I need to add any resistors or will the arduino more or less take what it needs? I plan on giving it 12v which is the boarder line for its 7-12v recommended voltage.

You should have both resistors in the LED circuit. R1 (in my picture) limits the current from the power supply through the LEDs, and R2 limits the current from the Arduino pin through the transistor Base/emitter junction (which is very like an LED with a 0.7V voltage drop, and does NOT self-limit current.)

I would think powering the Arduino from 12V (assuming it's a real 12V, and not an unregulated supply at 17V or so!) would be ok in this case since you'd only be powering the AVR, and it wouldn't take much current. If you were going to power the LEDs as well on the AVR side of the regulator, it would cause more power through the regulator, and be more of a problem.)

While westfw's circuit is good, if you are making R1 equal to only one ohm then you are in effect relying on the voltage drop on each diode being 2 volts.
Using so many LEDs in series with a voltage that close to the limit is not a good idea. There is no head room for any voltage variations in the LEDs.
Also just like Christmas tree lights if one goes short you will over current the others and blow them too.

Much better to have five in series and use a 100R resistor. That will give you 10 volts across the LEDs and allow 20mA to flow.

Wow that you for the great tips! When I hook my Arduino up to 12v can I expect the I/O's to still put out 5v?

When I hook my Arduino up to 12v can I expect the I/O's to still put out 5v

Yep because the Vin line is regulated down to 5V before it goes into the Arduino's micro processor so you still get 5V output, but that's fine that's what the transistor does, switch on a 5V signal.

Using the Vcc line connects the power direct to the processor if you connect that to the 12V you might expect get 12 V out of the I/O line, and you would if it were not for the fact that the arduino chip would burn in hell first. It has an absolute maximum working rating of 5.5v.

When I plug the power supply into the Vin and Gnd the board doesnt come on, but it will come on when I plug it into the USB. Have I fried my board?

No if you had fried the board it wouldn't work with the USB power. You probably haven't changed the jumpers.

I'm an idiot and you sir are my hero

Sort of a dubious distinction, isn't it? :wink: