Shorting Digital Output pins together - ok or not ok?

Hi,

The spec for an arduino mega says the digital output pins can source 40ma. If I want to connect a device that draws 70ma, can I connect it to two output pins if I always remember to turn them on and off together?

Cheers

Use a driver transistor of some kind. As you draw more current, the output gets further and further from 5V. And I'm not sure you can assure that the current is divided equally between pins.

Yes, you can do it but it is better to drive a transistor or other pass element to get more current. There may be a time when you have to parallel output pins because of space constraints or the for need a higher current push pull output.

You cannot parallel all the pins and get a maximum current equal to the sum of all the individual pin currents. There is another spec in the datasheet for maximum device current. Do not violate that spec.

Due to the max current constraints (ie if all the pins were high) it's not going to be 40ma per pin or rarther it will be up to a certain amount of current.

Then using resistors to balance the load....

It would work but I don't consider it a safe practice. If you're using digitalWrite() to manipulate the digital pins, there would be a very very small time lag between switching to both the pins to the same state as they involve two separate lines of code unlike in the case of direct port manipulation as in the case of AVR C. The best practice in such cases is to use some sort of transistor driver circuit or an off the shelf driver IC. That would be really neat and safe. Good luck.

Thanks everyone

OhMyCod:
The spec for an arduino mega says the digital output pins can source 40ma. If I want to connect a device that draws 70ma, can I connect it to two output pins if I always remember to turn them on and off together?

There's no reason why not. I've done it...

Remember there's a global limits though. eg. You can't join all the Arduino pins and expect 700mA...

You can't join all the Arduino pins and expect 700mA...

Or, IIRC, even six of them, and expect 200mA.

sreedevk:
It would work but I don't consider it a safe practice. If you're using digitalWrite() to manipulate the digital pins, there would be a very very small time lag between switching to both the pins to the same state as they involve two separate lines of code unlike in the case of direct port manipulation as in the case of AVR C. The best practice in such cases is to use some sort of transistor driver circuit or an off the shelf driver IC. That would be really neat and safe. Good luck.

Its safety is relative - perfectly safe for a finished project, the code works and only
drives the pins simultaneously using direct port manipulation, all tested and happy.

However if you prototyping and constantly uploading new sketches its all too easy to
get something wrong and end up driving the pins against each other.

So I'd say be careful,

As others have mentioned also check the max current for all pins (and I think there's
a limit per port too, but not sure - the datasheet will know :slight_smile:

And really... with transistors selling for 2 cents each or less in some places... it makes more sense just to by a bunch and build proper driver circuits.