I need to control 400 LEDs with an arduino mega

Hi, I have 400LEDs that I need to control with 24 pins (I want each pin to control approximately 15 LEDs). First of all can an arduino mega handle that? Also, I know that in these cases a transistor is what I need. How do I know what kind of transistor I need to get? Is there a specific formula? And finally how do I know what kind of power supply I need in order to be able to handle that. Sorry for the multiple questions, but I'm an amateur. I would really appreciate your help!

Not sure what kind of leds you are using? I am controlling a couple hundred ws2812b on a strip with one lead from the Arduino.

I have 400LEDs that I need to control with 24 pins (I want each pin to control approximately 15 LEDs).

Tell us more of what you are trying to do.

How do I know what kind of transistor I need to get?

You need to get one that can handle the current you want to switch.

Is there a specific formula?

No.

how do I know what kind of power supply I need in order to be able to handle that

You need the total current and what voltage you need from it.

In order to light an LED you need enough voltage to over come the forward voltage of the LED and then about the same again for the resistor.
You can wire several LEDs in series and only use one resistor. However that is not likely you can wire 400 / 15 = 27 in series. So you will have to wire several of these strings in parallel.

So what is the forward voltage of your LEDs and do you want to use a 12V or a 24V power supply?

Thanks for the help guys. I know I am not being very specific, but it's because I'm that good at this kind of stuff yet. I'm better at coding and I am trying to learn this stuff now. So what I am trying to make is an LED world map. It's a project for my masters program that I have to finish by Wednesday. You can see here what I have made so far (Imgur: The magic of the Internet). Every continent will have a different LED color. I am using regular 5mm LEDs (except from 20 LEDs that I am using for Australia that are the white super-bright ones). So as I told you earlier I am using an arduino mega and I want to use 24 pins. Obviously all of them will be in parallel, but the distribution is not proportional. There are some pins that I want to control only 3 LEDs with and there are other pins that I want to control 70 LEDs with. I have two problems. The first one is that I do not know how to do the math in order to determine what kind of power supply I need in order to power all of them, and what kind of resistors I need for each parallel. My second question is do I have to use transistors? Again, thanks so much for your help. Anything helps right now cause since I have to finish this by Wednesday, I am kind of freaking out.

Obviously all of them will be in parallel,

Well it is not obvious to me.
You can save a lot of current capacity if you put some in series.

For example if each LED takes 20mA then with 400 LEDs you need 400 * 0.02 = 8 Amps - that is quite a hefty power supply. However with three in seriese you can have a 12V power supply with only (400 / 3) * 0.02 = 2.6A a much more manageable supply.

My second question is do I have to use transistors?

Yes you certainly do.

what kind of resistors I need

Just carbon resistors will do. However I think you mean value. That depends on the LED's forward voltage drop and that is different depending on the LED and most of all it's colour. Once you know that you can calculate exactly what you need, however 220 ohms is a good ball park figure.

I drew this circuit for you.
It shows 5 sets of 3 series LEDs. You can just add extra groups of 3 for more LEDs if you want more.

The base resistor connects to the Arduino output pin and the power supply negative is connected to the Arduino's ground, as is the emitter of the transistor.

Thanks so much for your help. You are saving me. As far as the question concerning the parallel vs. series circuit, you are totally right. As I told you I am completely knew to this and I think that I am confused in my mind what parallel and series is. Series is totally what I want to do. As I told you earlier I want to make 24 sets of different number of LEDs in each. The reason is that I want to portray different kinds of demographics for each continent and thus I want to be able to turn on and off different parts of each continent. 24 sets (ranging from 5 to 80 LEDs in the set) is the minimum and most efficient way I can do it. My last question is what kind of transistors do I need? I just went to an electronics store and the guy there told me that I need simple pnp transistors. He gave me these ones (Imgur: The magic of the Internet). Are these going to work? Again thanks for all the help man. You are amazing!

I just went to an electronics store and the guy there told me that I need simple pnp transistors.

Sorry he is an idiot.

First you want an NPN transistor. That is what the diagram shows. The direction of the arrow on the emitter shows you it is NPN.

Next if there are a maximum of 80 LEDs in a set then the transistor has to be able to handle (80 / 3) * 20 = 533mA or 0.533 Amps. Therefore it needs to be a medium power transistor.

There are lots that will do this. One common one is called a TIP31.

Ahhh Ok. We have many TIP120 at school. Will those do? I'm sorry for all the questions. I promise this is the last one.

Yes a TIP120 will do, it is not actually a transistor but a darlingtom pair, that is it consists of two transistors. It has a higher saturation voltage which means it will get hotter than a TIP31 but is should be OK.

Hi, to reduce the component count, you could use Uln2803, which has 8 inputs and outputs so replaces 8 transistors. Max current is 500mA per output and 2.5A overall, but stay comfortably away from those limits. Where you need more (or even close to) 500mA, you can gang two inputs and 2 outputs together. You won't need resistors between the Arduino and the uln inputs, they are built-in, but you will of course still need series resistors for the leds.

Paul

Not sure where you get 2.5A overall figure from. Due to heat dissipation problems it is more like 600mA overall.

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

Mike, I read the 2.5A figure in a data sheet, the TI one I think. But I suppose if the darlingtons drop around a volt, that would be 2.5W dissipation, which does sound rather high... but 600 mA total sounds very dissapointing, less than many small transistors!

Oh well, I bow to your greater experience as always.

koumou92, better stick to the tip120 for all but your small groups of leds!

Or even better, a Low Rds, Logic Leve N-channel MOSFET for low power dissipation in the device:

AOI-516, AOI-518 also good choices.
I have 32 on this board with 74HC595 to drive the gates high/low to turn them on/off.
Send it 4 SPI.transfer(data) commands to update the board outputs as needed.
Couple clips of it working here:
http://www.crossroadsfencing.com/BobuinoRev17/

Depending on current, you might also look at open drain shift registers:
TPIC6B595 (150mA continuous for each of 8 outputs),
TPIC6A595 (350mA),
TPIC6C595 (250mA),
TPIC6A595 (100mA)

This board has 12 TPIC6B595 for sinking current from 12V LED strips

Bob, I think the 100mA version should have been the "D" variant?

So, what do we think the thermal dissipation (or other factors) will limit the total current to, for the tpic series? Hopefully more than the uln! The output fets should drop less voltage compared to those darlingtons, shouldn't they?

The thing is that the kid has the darlingtons already at school so why not use them. Yes the will get a bit warm but it should be OK.

I could have mixed up the currents a little, was bouncing between 3 windows trying to compile the info.
I've never run one really hot. Maybe just 65mA max on 7 of 8 6B595 outouts for 9-LED strips for hours on end from 12V battery with no issues, either SMD or DIP.

Use what you have. I built 13 scoring machines & remote light boxes for my fencing club. All are a little different as my assembling improved as I went and I played with the control board design based on parts I had on hand, mostly in the shift registers and 7-segment display area. The initial (large box) was rebuilt a couple times to incorporate things I figured out later, and added features. One of the parents is an actual embedded software engineer and he is looking into how to expand the software to handle Sabre for me - I only programmed in Epee, then got a new job and ran out of time for the really deep programming.
We don't fence Foil, so that's really low priority.

My view is that it is best to break it down into smaller pieces of information
that can then be used to help guide the design.
I'm a believer that a design should be driven by the feature requirements along
with some real world necessities and then take into consideration budget and time.

Before you can go off and starting designing anything, or anyone can offer any
reasonable suggestions on what you need or how to do it,
there are a few fairly basic questions that must be answered.

  • How many different & independent sections of light need to be controlled?
    i.e. how many separate groups of leds need to be controlled?
    Even though your title says you need to control 400 LEDs,
    I'm assuming you don't need individual control of each individual LED but
    rather are wanting to control all the LEDs for a given continent at once.
    So how many separate "things" do you need to control?

  • How much current do you need to feed an individual LED to get the desired brightness.
    For example, if this is to be used outdoors or in very bright light conditions, the LEDs
    will need to be much brighter and hence will need much more current.
    This is very important as the amount of current needed to drive an led that is easily visible
    indoors and one used outdoors can be more that 10X difference.
    i.e. in doors 1 to 2 ma might enough whereas outdoors you may need 20 to 30 ma.
    The best way to come up with this is to actually measure it.
    Hook up an LED with a potentiometer in series along with a meter and then adjust
    the pot to get the brightness you want and then see how much current it takes to get
    the desired brightness.
    (keep in mind that the different LED colors may use/need different amounts of current for similar
    looking brightness)

  • What is the maximum amount of current needed for individual light control?
    i.e. if you know that you need say 2ma for each LED and there are up to 25 LEDs
    in the biggest individual light control group then the circuitry needs to be able to switch 50ma.

  • Do you need dimming capability?
    "need" being the key word. Having dimming can complicate the design and
    increase its cost so make sure that dimming isn't just a "that would be cool" type of thing.
    i.e. do you need to be able to dim a continent vs just light it up?

  • Total current (can be calculated once you know how much for the individual LED)
    This will help determine how to appropriately size your power-supply.

Once this information is known then that will help direct the overall design.

--- bill