# Max current through an Arduino Mega?

How much current can I put through the pins of an Arduino Mega at the same time?

The situation: I am building a 7x7x7 LED cube, and my plan was to multiplex in 7 layers of 49 pins, lighting each layer, one at a time. This would mean each pin on the Arduino Mega would only have to supply max. 1 LED at a time.
However, if all 49 LEDs in one layer were on, it would presumably draw 49*20mA (from the LED specs sheet), which is 980mA. This seems like quite a lot of current to put through an ATMega chip, so I was wondering if I could do it, either continuing like this, or using transistors to control the lighting of each layer, or what?
Any help or advice is appreciated!

EDIT: Using ATMega2560, not ATMega328 or alternate.

• What does the ATMega datasheet say? The maximum output current on microcontrollers I've used is around 20 mA, so your 980 mA is totally out of range - you'll need transistors to handl that much current. – Peter Bennett Mar 21 '16 at 17:29
• @PeterBennett Yeah, the datasheet says the 20mA is per pin, and for an Arduino Uno. For an Arduino Mega, per pin is 40mA. The 980mA figure quoted is in total, over 49 pins. – TheAbelo2 Mar 21 '16 at 17:32
• Possible duplicate of Real maximum current for ATmega328? – Passerby Mar 21 '16 at 17:46

The ATmega 2560 (assuming that's the chip on your Arduino Mega) has an absolute limit of 40mA on each pin, and 200mA in total for all pins. So yes, you will not be able to drive that load directly from the Arduino.

With external circuitry however, anything is possible. If it were me, I'd use some TPIC6B595 IC's to drain current and BC635 NPN's to source it.

The 595's can sink up to 150mA each (so up to 8 LEDs at 18.75mA each, use a 270Ω resistor in series with each LED if you're running everything from 5V.) You would need 7 595's for 49 LEDs (49 / 8 rounded up.)

You can daisy chain the serial in/outs on them so you just need to shift out 8 bytes from the Arduino (either using SPI or the software equivalent, shiftOut or whatever it's called, on any digital pin.)

TPIC6B595N Datasheet

To source current, BC635's are rated up to 1A with a typical current gain (hFE) of 100. Collector pin goes to 5V, Emitter pin goes to all the LED anodes on a layer, Base pin connects in series to a 510Ω or 470Ω resistor and an Arduino digital pin. You would need 7 635's, one for each layer. They turn 10mA from a digital pin into 1A from the power supply.

BC635 Datasheet

Speaking of power supplies, you will not be able to power the whole thing from the Arduino 5V pin (especially if powered from USB.) You will need an additional 5V power supply. If you want simplicity you could use a L7805 voltage regulator and stick a heatsink on it.

L7805 Datasheet

All of these are popular components which can be obtained from eBay for next to nothing.

If you have more questions specific to Arduino, they might be better suited to the Arduino Stack Exchange.

• I should mention that by multiplexing each LED will only receive 1/7th of the current over time. That is to say, if you were putting 18.75mA through each LED they would only get the equivalent of 18.75mA / 7 (2.68mA.) – Ashlyn Black Mar 22 '16 at 3:33
• So what if I went over the max recommended current for the LEDs? I asked for 180 ohm resistors and I got given 150 ohm instead at Maplin's, and didn't check before I was out. The blue LEDs have a voltage drop of 3.3V which gives 3.3/0.150 = 22mA, which is over the recommended 20. But since I am multiplexing, this means I'd have an equivalent of 22/7 ≈ 3.1mA? – TheAbelo2 Apr 5 '16 at 19:00
• Ummm I think that should be (5V - 3.3V) / 150Ω = 11mA so you're fine in either case. – Ashlyn Black Apr 9 '16 at 14:47

You're on the right track here. In the datasheet for the ATmega1280 I find this box:

What you want to look at is `DC Current Vcc and GND Pins .... 200.0 mA`

This is the total limit of all the current going through the chip (because everything must come through Vcc), and it is the absolute maximum. Don't go near it. You need to boost this with some transistors.

It's listed in the Electrical Characteristics of the specific MCU used in the Arduino you have.

For the Mega2560, its remarkably similar to the 328 in the Uno.

Absolute Max, 40mA per pin, 200mA VCC or GND current. 20mA per pin recommended max. A huge note, various ports have individual limits:

3: Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega1281/2561:
1.)The sum of all IOL, for ports A0-A7, G2, C4-C7 should not exceed 100mA.
2.)The sum of all IOL, for ports C0-C3, G0-G1, D0-D7 should not exceed 100mA.
3.)The sum of all IOL, for ports G3-G5, B0-B7, E0-E7 should not exceed 100mA.
4.)The sum of all IOL, for ports F0-F7 should not exceed 100mA.
ATmega640/1280/2560:
1.)The sum of all IOL, for ports J0-J7, A0-A7, G2 should not exceed 200mA.
2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.
3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200mA.
4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100mA.
5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.

4: Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega1281/2561:
1)The sum of all IOH, for ports A0-A7, G2, C4-C7 should not exceed 100mA.
2)The sum of all IOH, for ports C0-C3, G0-G1, D0-D7 should not exceed 100mA.
3)The sum of all IOH, for ports G3-G5, B0-B7, E0-E7 should not exceed 100mA.
4)The sum of all IOH, for ports F0-F7 should not exceed 100mA. ATmega640/1280/2560:
1)The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed 200mA.
2)The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.
3)The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200mA.
4)The sum of all IOH, for ports E0-E7, G5 should not exceed 100mA.
5)The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100mA.