Digital Pins As Ground

I have LED's that I want to run off pins now I was thinking of using a transistor for each LED to amplify it. I had another idea though and I want to check here if it is okay. if I plug an LED (positive leg) to 5 volts (through resistor of course) and put the ground to a digital pin, Would it not use the digital pin's power when I set it to high or low?

It would be sinking the current as opposed to sourcing it. Its still 40 mA tops.

Yes. If you hook-up a LED between +5V and a digital output, the LED will come on when the output goes low. (Off when the output is high). Assuming correct polarity and the correct current-limiting resistor, of course. :wink:

This is known as "sinking" current. The Arduino pins can "source" or "sink" about 40mA (more than enough to drive one regular LED). Some digital chips can sink more than they can source.

If I have a lot of Led's do you think I should just use a transistor on each one?

The Arduino pins can "source" or "sink" about 40mA (more than enough to drive one regular LED).

No, no, no.
One AVR pin can source or sink at the ABSOLUTE MAXIMUM 40mA.
Don't go anywhere near this figure.

If I have a lot of Led's do you think I should just use a transistor on each one?

Preferably, yes, or per string if that's how you're driving them.

That depends on how you plan to connect them.

One per IO pin, and less than 20mA current? Then no transistor.

Two in parallel from 1 IO pin and less than ~35mA (40mA absolute max) total current? Getting iffy.

Two or more in series from a >5V source, or 3 in parallel? Transistor for sure with resistor going to base of NPN transistor, emitter to Gnd, collect to cathode of LEDs, Anode of LEDs to +V source. NPN sinks current to turn the LED(s) on.
Another handy part is ULN2803, equivalent to 8 transistors/base resistors.
Or TPIC6B595, combination shift register & high current capacity sink.

The datasheet says > 20mA source or sink is not guaranteed at 5V, and > 10mA source or sink is not guaranteed at 3V. So I try to keep under those. Usually.

There are also some interesting aggregate limitations, in addition to the overall chip aggregate of 200mA. For instance, the nine Arduino pins 5-13 together should not source > 150mA and should not sink > 100mA. So wire the loads to ground if there is a choice, and let the pin source the current to the load.

29.2 DC Characteristics

Notes
3. 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:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.

  1. Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
    conditions (non-transient), the following must be observed:
    ATmega48A/PA/88A/PA/168A/PA/328/P:
    1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100 mA.
    2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100 mA.
    3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100 mA.
    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.

Glad to see those limitations are being remarked upon by others (and not just me)!