I´m new working with Arduino. Right now I have a project thar requires to turn on 30 LEDs at the same time with an Arduino Mega. The problem is that it would exceed the max current that the chip can tolerate.

It is possible to do this by turning on one LED at the time, very fast?

If it is, any clue on the code to achieve that will be apreciated.

Thank you very much

P.S.: I know there are components to expand the quantity of pins that work like that, but the idea is to avoid using one.

  • Do you need to run them at high brightness (=high current)? Strobing them will have the effect of reducing the brightness, and if you don't need high brightness then you can use higher current-limiting resistors so save the effort of strobing them. If you need them to be bright, you'll need some sort of driver - the right transistor will probably be sufficient. – Mark Smith Jun 15 '17 at 8:56

This page explains that the ATmega2560 could drive up to 800mA: Arduino Playground: Arduino Pin Current Limitations
There are limitations for groups of pins, so you have to be careful.
The 800mA is a lot in my opinion. I wonder how hot the chip will become.

What kind of leds do you use ? Normal 20mA leds ? Or is 10mA leds also possible ? 30*20mA = 600mA, but 30*10mA is only 300mA. The 300mA seems a lot safer to me.

With Charlieplexing the leds are not 'on' all the time. However, with the Arduino Mega 2560 you have enough pins, and you could just lower the current through the leds.
Turning them on for a short time (without Charlieplexing) is the same as turning them continuous on with a lower current.

The most common way to drive 30 leds is with a led strip. For example a led strip with neopixels. That led strip has to be powered seperately.

My advice is to lower the current for the leds to 10mA and hope that the ATmega2560 doesn't get too hot.

[ADDED] 300mA is still a lot. Start with 5mA per led for a total of 150mA when they all are on at the same time. Many modern and good quality leds are bright at 5mA.

  • 1
    Note that, if the LEDs are not blue nor white, and if the don't have to be individually addressed, they could be wired by pairs in series. – Edgar Bonet Jun 15 '17 at 7:30
  • usually, 10ma is not much "dimmer" than 20ma, so if it's not for illumination nobody will notice. – dandavis Jun 15 '17 at 12:18

Use external drivers, like a transistor.

If you have to tie them to the avr, use large or larger current limiting resistors. Or to multiplex so only some of them are on at a given time.


Use the MAX7919. It is a driver for multiples leds. It lets you output up to 64 leds at a high enough brightness.


Its usually made to drive LED matrices or 7-segments LEDs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.