2
\$\begingroup\$

So, I know Ohm's Law and that Arduino UNO R3 pins (digital 2 to 13) have a rated maximum of 40 mA, although it's better to consider that they have a maximum of 20 mA for safety reasons. If I put 2 LEDs (say red ones which have the lowest voltage of 1.8 V) with a 330 Ohm resistance to each one in parallel, meaning that (from Ohm's law) each LED needs 9,96 mA current.

mA = [ (supply voltage - LED voltage) / R] * 1000 --> mA = [ (5 V - 1,8 V) / 330 Ohm] * 1000 = 9,96 mA

That means that both LEDs draw 19,92 mA current from an individual pin (correct me if I made any mistakes with calculations or prallel and series connections). So, can I plug a total of 26 LEDs (2 to each individual pin of the 13 in total) without damaging my Arduino??? Otherwise, how can I plug in as many LEDs as possible?

\$\endgroup\$
6
  • 1
    \$\begingroup\$ As many LEDs as possible means use a mosfet or relay. As many LEDs directly to digital pins usually means 200mA total max (spread evenly over at least 5 pins) \$\endgroup\$
    – Abel
    Commented Apr 13, 2021 at 5:11
  • \$\begingroup\$ So I need a mosfet. If I spread them evenly as you said in just 5 pins it will fry my Arduino, won't it? \$\endgroup\$ Commented Apr 13, 2021 at 5:34
  • \$\begingroup\$ or use ULN2803 or UDN2981 500mA max source/sink high side/low side 8 channel drivers. Each driver can independently driven and controlled by Arduino. See more details in this Q&A: electronics.stackexchange.com/questions/559680/…. Cheers. \$\endgroup\$
    – tlfong01
    Commented Apr 13, 2021 at 6:05
  • \$\begingroup\$ Thanks a lot! I'll check it out. \$\endgroup\$ Commented Apr 13, 2021 at 6:15
  • \$\begingroup\$ And in case you don't have too many Arduino GPIO pins to go around, you can ask this little guy for help: (1) I2C PCF8574 Remote 8-Bit I/O Expander - TI ti.com/lit/ds/symlink/…. Each PCF8574 can entertain 8 bidirectional I/O, and it is so newbie friendly that there is not user programming need to config the GPIO pins. So now you can placed 8 PCF8574s on one I2C bus to control 8 ULN2803/UDN2981, ie, Wow, 64 LEDs! \$\endgroup\$
    – tlfong01
    Commented Apr 13, 2021 at 6:49

2 Answers 2

2
\$\begingroup\$

You are mistaken, the pins do not have a rated maximum of 40mA. That is the rating of permanent damage happening, and very much outside of normal operating conditions.

The rating for normal use conditions for a single pin is 20mA.

Also do note that the pin voltage is not any more 0V or 5V when 20mA flows, it is guaranteed to be max 0.8V sinking 20mA and min 4.1V sourcing 20mA.

But there are also other limits.

There are three pin groups which each are limited to sink 100mA, and there are two pin groups which each are limited to source 150mA.

The MCU total limit is listed in the absolute maximum ratings, again which does not mean normal usage, is 200mA.

So this basically means, no, you cannot plug a 20mA load on each GPIO pin and expect it to work.

Due to the limits, that's less than 10 loads of 20mA for the whole MCU, but due to the group limits, it must be below 11mA per pin.

What you need is the MCU to control some sort of LED driver that can handle the load.

\$\endgroup\$
1
\$\begingroup\$
  1. It is a bit risky to burden the little poor weak Arduino with so many LEDs. I would suggest to ask the strong guys for help: 8-channel 500mA max source/sink drivers ULN2803/UDN2981 to drive common Anode/Cathode LEDs.

  2. In case greedy you don't have that many Arduino GPIO pins to go around, you can ask another guy for help: PCF8584 8-channel I/O pin expander. One I2C bus can squeeze in 8 PCF8574s, and now Wow! you can mess around 64 LEDs with just two I2C wires.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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