Switching a lot of leds on and off

Hi i was planning on connecting multiple leds to one pin by using a transistor in between. So my question is, if i were to connect 50 leds could the Arduino handle the current when i don’t use any external power supply and if not how many could be handled?

thanks in advance.

Depends on the model of Arduino, but most can only handle a couple of hundred mA before their regulators overheat. So maybe 10 leds @ 20mA each.

If you decide to get an external PSU, you have 2 alternatives:

  1. Get a 5V one. Then you can run as many leds as you like (up to, say, 80% of the PSU's current capacity) because you can bypass the Arduino's regulator and power it by the 5V pin. Each led will need its own series resistor.

  2. Get a 12V one. You can run groups of 3, 4 maybe 5 leds in series, only one series resistor needed for each group. More efficient also, as less power wasted in series resistors. Arduino can be powered through its regulator (provided minimal extra components are powered from 5V) by connecting to barrel socket or Vin pin.

In either case, do not draw the full power of the PSU through the Arduino board. Take separate power lines to the leds and to the Arduino.

alright thanks. im guessing i will be going with the external power supply option then. can you recommend any specific power supply in the 12v range?

also because i currently only have a transformer which is for model railways and such things. it can supply up to 14v dc and 0.6A. could i theoretically use that one aswell? Still not a lot of current but better than the arduino itself im guessing.

14V is too high to power an Arduino through its on-board regulator. You could use an external regulator, but it would also be in danger of overheating, so would need to have a heat-sink attached. Alternatively, use a DC-DC converter module to create 5V to power the Arduino. Use the 14V supply to drive the LEDs directly. You could group probably 6 leds in series, with a single series resistor for each group.

ok just to clarify this because im kind of confused now. Is there no way to feed this power from the transformer to the leds without it going through the arduino? Because i thought i could just connect it to the leds with my plus and minus cable and then use the usb jack to power the arduino with my pc and make it so i can switch it somehow with my arduino pins on and off.

Xifios:
Is there no way to feed this power from the transformer to the leds without it going through the arduino?

I am saying that is exactly what you must not do. Sorry if my explanation confused you!

You can also power the Arduino from the 14V supply, instead of from the PC, using an external regulator (with heat sink) or a DC-DC convertor module. You would run a separate pair of power cables from the PSU to the Arduino, so that the LED power does not flow through the Arduino board.

If you wish to power the Arduino from PC/USB power and the LEDs from the 14V PSU, you must still connect the grounds together. If, for some reason I am unaware of, you can't or don't want to connect the grounds, you could use an opto-isolator.

ok i worked out two really simplified circuits. would either of this work if i use my 14v supply or are those designs generally flawed? and if this works can i then safely connect as many leds as i want to up until those 80% of the external power supply A limit or will i still have to keep the arduino limitations in mind?


The above looks OK.


The above could damage the Arduino. Without the transistor, you are exposing the Arduino pin to a voltage highter than its own supply (=5V).

ok, so if i go with the transistor circuit i pretty much only have to worry about how much current the transistor can handle? so in my case i would be using N2222 NPN which i gues should be enough for at least 30 leds since its rated at 600mA. so 3 strings with 3-4 leds and the strings each in parallel. Would this work?

Xifios:
... at least 30 leds ... 3 strings with 3-4 leds

I'm a bit confused how many leds you are asking about! 30+ or 9~12?

Although the max current of the transistor is 600mA, its probably best to keep it well under that to avoid overheating problems.

With 14V supply, you may be able to organise leds into groups of 6 in series for red leds, or 3 in series for white leds. Each group will draw about 20mA. So for 30 red leds, that would be 5 groups x 20mA = 100mA. For white leds it would be 10 groups x 20mA = 200mA.

sorry i was a bit unclear about what i wanted to say. What i mean is i could probably run 3 strings that each have 3 white leds in series and those strings then parallel to each other and all of this going through that one transistor. so in total 9 leds which are all controlled by one pin.
But running 30 leds in total wouldn't a problem either just using that one transistor right?

Right. Don't forget you will need a series resistor for each group of 3 LEDs. If the forward voltage is 3.2V and the max current is 20mA, the resistor should be (14 - 0.7 - 3 * 3.4) / 0.020 = 155R. 150R should be ok. The 0.7 is the voltage that will be dropped by the transistor.

Xifios:
also because i currently only have a transformer which is for model railways and such things. it can supply up to 14v dc and 0.6A. could I theoretically use that one as well? Still not a lot of current but better than the Arduino itself I'm guessing.

If it is "for model railways and such things" I would presume it is a simple transformer-rectifier and has an output which may be 14 V under certain conditions. :roll_eyes:

This leads to the "XY problem" consideration. What do you actually want to do with all these LEDs?

well it has a regulator on top so it can go from 0 to 14v pretty much.
This will be more or less my first project in terms of using electronics. (Im actually comming from a programming only enviroment so for me the real challenge lies in understanding how these circuits work). Ultimately I want to program a small Android app with which i can control those leds via a bluetooth receiver.
Just simple things like making them blink, fade, dim and perhaps a little lightshow but nothing really to spectacular at first since this is my first project after all^^

Be aware that those model railway transformers supply only a rectified AC voltage. No capacitors, no regulators.

Xifios:
well it has a regulator on top so it can go from 0 to 14v pretty much

Hmm… Have you measured it? With no load attached, what voltage is actually output, at 50% and 100% control setting? Is it a train speed controller? It could be pwm…

Xifios:
well it has a regulator on top so it can go from 0 to 14v pretty much.

That tells us little. Sounds like a model train controller with a variable resistor, but nowadays it could be anything and in any case sounds quite unsuitable for the purpose of powering LEDs.

Xifios:
Just simple things like making them blink, fade, dim and perhaps a little lightshow

Hmm. I thought as much.

If you wanted the light-show and blink but not the fade and dim, I would suggest a MAX7219 with one of the eBay matrix modules re-purposed to your own array construction.

If you want fade and dim of just one group - all at once - then a logic-level FET (see discussions on these forums) and some switchmode power supply is what you would use.

If you want blink, fade, dim and a light-show with many independent LEDs, with colour to boot, you want what are broadly called "NeoPixels". You will want a fully regulated 5 V (switchmode) power supply to match. If just a few, a "Phone charger" is usually practical.

would this work?

Yeah, should be ok.

(I'd appreciate it if you could learn to post your own pics and links properly)

PaulRB:
(I'd appreciate it if you could learn to post your own pics and links properly)

sorry, I will keep that in mind for future posts.

Btw. thanks to all of you for helping me out with this matter and actually sticking around. This is probably the most basic stuff to all of you so thanks again for taking the time to help a noob in need out.