setup for a bunch of leds

hey there,

i have to connect these leds to my arduino:

2 x 34,
1 x 22,
1 x 30,
1 x 28

i want to be able to switch on and off the groups.
this are the leds:
Uf: 3.05 V
If: 20 mA

since the output pins only have 20(40) mA will have to use an external power supply.
what is the most elegant way to do this?

thank you guys
<3

4 groups?
Wire up parallel strings of 3 LEDs and a resistor, power the strings from 12V, and use a transistor per string to control them on/off.
An AOI514 would be a good transistor for each group. Use 220 ohm between Arduino and Gate, and 10K from Gate to Gnd.
http://www.digikey.com/product-search/en?vendor=0&keywords=aoi514
LED strips would make it quick to assemble also, see pages 3 & 4 for examples.
http://www.dipmicro.com/store/index.php?page=2&searchStr=led&act=viewCat&Submit=Search

Hey CrossRoads,

thank you for the fast reply!

i expected something like this. all in all i have 5 groups (34-22 leds each). you wrote "a transistor per string" and later "a good transistor for each group". should i use transistors for the subgroups (3 leds + resistor) or one to rule them all (one for the group). if not, how much mA do you think it should be able to survive? I prefer buing any transistor i can order from conrad.com and i'm looking for the requirements.

Did I get you right and this is the setup for one group (of 30).
(I need to calculate the resistors for the string and just took 220)

R12 is not needed and it will make the circuit not work. Connect the emitter of the transistor directly to ground.

Please correct me, if I'm wrong, but this would be my calculation:

Every string (3 LEDs and 1 Resistor) get's 12 V.
Every LED should get 3,05 V and 20 mA, so there're 2,85 V left.
R = V/I = 2,85 V / 20 mA = 142,5 ohm (150 ohm)

The group has 10 strings with 20 mA each, makes 200 mA/group.

If I take an BC328 transistor I have these values:
hFE = 30
Ib = 200mA / 30 = 6,67 mA
Ue (taking 10%) = 4,5 V
Ube = 0,7 V
Rb = (4,5 V - 0,7 V) / 6,67 mA = 570 ohm (500 ohm)

Now I'm not sure how to get the groups together with one power supply. (That would need max. 5x200mA)
Should it not be possible to set them parallel?

The figures look ok although I would give it more base current to be on the safe side, say a 330R.

Yes they are in parallel as you have drawn them and you do need 20mA for each run of three LEDs. The current does add up.

Thank you.
Than this would be my final setup:

will a single led in a string be equally bright (when i use 470 instead of 150 ohm)?
And will the groups be equally bright if i only one / two etc. (if i have a power supply that supports more than ca. 1A

I double checked your resistor values and it looks like you have everything calculated correctly. And yes they should all be equally bright.

Google says the BC328 is a P channel transistor. You are sketching and using it as an N channel transistor.

I have concerns over the switch S1, there are three inputs and at any time two of them will be floating.
Change it so that the wiper of the switch simply connects one out of the three inputs directly to ground, then enable the internal pull up resistor.

Google says the BC328 is a P channel transistor. You are sketching and using it as an N channel transistor.

To be strictly accurate a "p channel" or an "n channel" only refers to FETs. What you have with a BC328 is a PNP transistor. If you use that in your circuit it will not work.

Thank you guys.
Of cause you're right and I bought the wrong transistors. Do you have an idea how to change the circuit to make it work with them, or do I have to buy new ones?
And the switch could not work as well. I'm not sure wether I understood you right, but wouldn't it work like this as well?

Do you have an idea how to change the circuit to make it work with them,

In order to use the transistors you have you will need to supply a 0 and 12V signal from the Arduino to drive the base.
To do that you will need an NPN transistor so you are not saving anything in your case as you have to buy them as well. Therefore you might as well just buy the right type and replace them.

And the switch could not work as well. I'm not sure wether I understood you right, but wouldn't it work like this as well?

Well what you put will work. I am not a great fan of pull down resistors. I was suggesting the wiper of the switch goes not to 5V but to ground, and the pull down resistors are removed altogether. Then on those three inputs you enable the internal pull up resistors. See this for a full discussion:-

http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

I replaced the transistors with bc33740s. The hFE should be equal so the resistor values don't change.