I was wondering since a micro controller can sink 20 mA on each pin, if I can make 4 pin ports low by software, and just connect the positive side of the load to Vcc, is this a reliable methodology for driving larger loads? Would the only thing to worry and pray about is that the machine cycle is fast enough to handle the fluctuations of setting all the pins at the same time? Am I on the right track?

  • 4
    \$\begingroup\$ The chip will also have a total maximum ground current. You should not exceed that! \$\endgroup\$
    – Daniel
    Feb 16, 2016 at 22:37
  • 11
    \$\begingroup\$ Data sheet information is generally considered superior to praying. \$\endgroup\$
    – gbarry
    Feb 16, 2016 at 22:39
  • 2
    \$\begingroup\$ @Daniel on an arduino chip max is 200ma. \$\endgroup\$ Feb 16, 2016 at 22:45
  • 5
    \$\begingroup\$ How is this off topic? It's specifically about electronics design \$\endgroup\$
    – Passerby
    Feb 18, 2016 at 3:02
  • 3
    \$\begingroup\$ I don't remember if its Atmel or TI that has a small note about paralleling GPIO for this exact purpose, mainly due to the voltage droop from too high current pull on a single pin. As long as the total current through vcc/gnd pin is within spec, and you always set the pins in the same instruction it would be fine. A Darlington Array like the ULN2003A specifically mentions paralleling for higher capacity per channel. \$\endgroup\$
    – Passerby
    Feb 19, 2016 at 15:43

6 Answers 6


It should work just fine, but You need to keep in mind a few things.

  1. Max VCC or Max GND current. There is a maximum current that the microcontroller can support through its VCC or GND pin.
  2. Max Port current. An individual port has a maximum current as well.
  3. Pin ESR. A GPIO Output will have a voltage drop (or rise) based on how much current is going through it. Typically, the recommended max current through the pin is for a given output voltage compared to VCC or GND.

enter image description here
Ex: The MSP430G2xxx family Voltage Output Low will rise 1 Volt from Gnd, at ~30mA.

If your load is within these specs, which your 80mA load example should be for ATMega micro controllers, then the other concern is preventing shorts.

You need to ensure that you change the entire Port at once, instead of one pin at a time. If you change only one pin at a time, from Low to High or High to Low, then you can create a dead short between the pins, blowing one or more of them. Depending on the default state of the pins when starting up, before your code can set them, this may not be avoidable without extra parts. Also try to keep it isolated to a single port, as it will be difficult to change multiple ports at the same time, and voltage differences between ports may hurt.

Typically, having series resistors on the pins will help. These resistors will end up in parallel with each pin as well, which helps regulate the current between them.

Assuming you want the 80 mA load equally on 4 pins, then that's 4 extra parts, as protection. At that point, you may as well just go with a single transistor + resistor pair.

With careful coding, you should not need these, and parallel gpio will work fine as current sinks.

Open Collector outputs, which can only pull low, do not have issues with shorts, but should still be changed at the same time. Not changing them at the same time can lead to the current though just a single output, which will cause issues if there is no current limiter. A typical microcontroller GPIO is not Open Collector, but you can mimic it by only switching between Output Low and High-Impedance Input mode.

  • 1
    \$\begingroup\$ If the OP is just sinking current, as the question implies, and the pins are configured as open-drain, then the pins won't actually short out, even if they weren't all switched at the same time. But the pins should be switched at the same time to equalize the load across all of them (unless they aren't all on the same port). \$\endgroup\$
    – tcrosley
    Feb 20, 2016 at 2:38
  • \$\begingroup\$ @tcrosley but most mcu gpio are push pull, not open drain. But I'll add that in too. \$\endgroup\$
    – Passerby
    Feb 20, 2016 at 2:43
  • \$\begingroup\$ @Passerby - most MCUs offer an open drain output configuration, and even those that do not can have the same effect achieved by using the output enable / direction instead of the pin data register. Effectively you write the pin data register to a low while it is an input, and then set it as an output. \$\endgroup\$ Feb 20, 2016 at 18:54
  • \$\begingroup\$ @ChrisStratton yes, that's why I said mimic it. But do they really? The 3 most common MCUs I know are Atmel, TI, and Microchip and I haven't seen any open collector outputs on them. \$\endgroup\$
    – Passerby
    Feb 20, 2016 at 19:02
  • \$\begingroup\$ Those are brands, not MCUs. \$\endgroup\$ Feb 20, 2016 at 19:22

If not buying a "module" is your issue, consider spending 6 cents (or less) on a transistor that will happily sink 200 or 500 mA and only occupy one pin for its base control input. I think 6 cents is what I paid for the last batch of 2N3904/6 and 2N4401/2 in lots of 100. Not much point in buying less than that, but if you like paying 4X as much for one at a time, be my guest.

These are very far from cutting edge parts, but they do a particular sort of job well and they are pretty low cost.

  • 2
    \$\begingroup\$ The issue is probably not cost. The issue could be more like simplicity, space and not using stuff that isn't really necessary. You would also need a base resistor to limit current into the base. Even if it were a mosfet I think you would still want a gate resistor. If you really understand the power requirements well, I think there are many instances where you can do without outboard drivers. \$\endgroup\$
    – squarewav
    Feb 16, 2016 at 23:10

Don't ever connect a digital port to ground if its push pull or Vcc or ground if its open drain. Check the datasheet, I think the rasp pi doesn't have a datasheet but the info is out there. Sinking is different than sourcing. If you have an open drain output, you can sometimes sink more current than a push pull. You might be able to get away with a little more with a paralleled open drain configuration, because you aren't dissipating a lot of power in the chip but you still are limited by the wire width, if you go beyond this it will heat up and burn away.

With push pull this is generally a bad idea, you can parallel pins on your processor to give you more current, but you don't get more current through the Vcc Io or the I/O voltage supply pin. In some cases digital devices will give you a current rating on the Vccio and the pin itself. Don't exceed these ratings.


To me, despite the idea that it might work if all goes right, it's a really bad idea because it would be so easy to smoke things if you got one line of code wrong, or something bad happened while downloading code. Just bad practice


Don't guess, don't pray, don't test, just follow the datasheet, and treat it as your God.

Whilst I agree it can be a bit esoteric, each pin or category of pins will have recommended maximum currents (either sourcing &/or sinking). There's also likely to be maximums for the whole port of 8/16/32 pins, and/or a maximum source/sink for the entire chip's i/o pins. Read the datasheet, do the math, get the answer. Just to complicate matters even further, some MCUs allow you to program how much maximum-sink/source-current they'll operate at (e.g. the i/o on a BeagleBone's TI MCU). All the platforms/MCUs you mention are different.

There is danger in simply connecting several i/o pins together and using their combined current sourcing or sinking capability, and it's not the per-port or per-chip maximums I mention above; MCUs aren't meant to be power shunt devices, that's why they're called microcontrollers. It's:

(a) what happens to those i/o's when the chip's in RESET? Most will go high-impedance input, which is probably OK, but sometimes a pin will have some special purpose that may come into play during or immediately after a reset, in which case, what's your circuit going to do in that time, & how much current through that pin?

(b) the technique by which you set/clear those i/o pins: did you use only the pins from 1 port, in which case you can write a byte/word into the i/o register and set/clear them all at once, so they'll all start conducting all at once - great. But if you spread the load across pins from multiple i/o ports (i.e. Port A & Port B), then that requires multiple register writes, which happens sequentially, which means the first pins/port that is written conducts first and carries the total current, then it won't be until the next/last port is written that the current is shared roughly equally across all the pins you've connected to. If you're doing this i/o writing a single pin at a time (e.g. Arduino's "didtalWrite(Pin,State)", then that first pin will conduct the FULL current until the 2nd & subsequent pins are written. This is all BAD and likely to kill the MCU, if not immediately, then well within its expected life-time.

The solution is simple. Get a NPN transistor or N-ch MOSFET of suitable spec, connect its base/gate to the MCU's i/o pin (and calculate an appropriate series resistor between the two), connect its Collector/Drain to whatever it is you want to switch on/off, and connect its Emitter/Source to Ground. 1 i/o pin, 1 transistor, good for anything from tens of mA & beyond. There'll be other questions on SE on how to do this in detail.

  • \$\begingroup\$ Every once in a while, the data sheet is not God. I give you this example: ti.com/lit/ds/symlink/lm4040-n.pdf. Hooked up the TO-92 package according to the pinout on page 4. Didn't work. That's because the data sheet is wrong. It's not the top view, it's the bottom view. An older version of the same data sheet gets it right: adafruit.com/datasheets/lm4040-n.pdf \$\endgroup\$ Feb 21, 2016 at 16:10
  • \$\begingroup\$ No one's perfect, not even chip designer gurus, and you can cite rare exceptions till the cows come home, but relative to all the other suggestions (in this question & particularly it's incorrect bouncing to Arduino.SE which is where I answered it), the data sheet is God compared guessing, praying, and worse still "testing" it by drawing more and more current until the chip starts to get warm (a case of "You know that line you're not supposed to cross? Look behind you.") \$\endgroup\$ Feb 21, 2016 at 18:16
  • \$\begingroup\$ I don't know if you can get away with the "data sheet is God" argument, in light of Willis's counterexample. Saying the "data sheet is your God" is like saying "The Honda Civic is hands down the best vehicle on four wheels that has ever been designed by human hands" because you're comparing that Civic to old rusted bicycles. At the very least put a footnote that explains that datasheets are really just next to Godliness (right next to "cleanliness") \$\endgroup\$
    – Cort Ammon
    Mar 3, 2016 at 1:16
  • \$\begingroup\$ That's a semantic self-flagellation, which I already addressed in my reply to Willis. \$\endgroup\$ Mar 3, 2016 at 6:21

Several concerns spring to mind.

  1. What if you make a mistake in the code and drive one pin high while another is low? You now have a power to ground short through a pair of IO pins which is not good.
  2. Are there any restrictions on total maximum current for the IO pins. If so are you within those limits
  3. How well balanced are the drive transistors. I.E. How close to equally will they share current initially.
  4. What is the temperature coefficient of the output transistors. As imbalanced current causes unequal heating of the output transistors will that make the current balance better or worse.

Concern 1 is mostly a case of how much condidence you have in your own code. Concern 2 is something datasheets can answer but I don't think i've ever seen a datasheet that answers concerns 3 and 4.

As such I would not recommend this configuration. Use an external transistor to switch the load.


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.