330 ΩATmega328Pred LED220 ΩSDG12 V strip12 V1digitalWrite(8, HIGH);2digitalWrite(9, HIGH);3digitalWrite(9, LOW);pin 80 mA020 tested40 maxpin 8pin 9GND9.4 mA250 mA5 V0 V
Back: the chip, an LED on pin 8, a MOSFET on pin 9 switching a 12 V stripFront: the firmware card and the pin-current gaugeTokens: currents and gate voltages as they moveAn ATmega328P pin may give at most 40 mA (absolute maximum) and is only tested to 20 mA. A red LED with 330 Ω takes about 9.4 mA: fine. A 12 V, 3 W strip needs 250 mA: far too much. An IRLZ44N MOSFET switches the strip: the pin only charges its gate, and the 250 mA loops through the supply, the strip and the transistor to ground.

What a pin can give

  1. Inside the chip, each output pin is a pair of tiny transistors. HIGH connects the pin to 5 V, LOW connects it to 0 V. Any current a part draws from the pin flows through them.

A transistor carries the load

Switching it from code

What happens

;; step 1/9 · pin-switch
output pin   two tiny transistors inside the chip
  HIGH       pin -> 5 V   (it sources current, out of the pin)
  LOW        pin -> 0 V   (it sinks current, into the pin)
whatever you connect draws its current through them

Absolute maximum ratings are damage limits, not working points. The datasheet also caps groups of pins: the current out of one port group should stay under 150 mA and into one group under 100 mA. Arduino's own guide suggests a 470 Ω or 1 kΩ series resistor on outputs. The gate is like a tiny capacitor. The IRLZ44N needs at most 48 nC to charge, so at 22.7 mA or less it takes at least 2.1 µs; in practice a few microseconds, because the current shrinks as the gate fills. The steady gate leakage is at most 100 nA.