What a pin can give
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.
digitalWrite(8, HIGH) puts 5 V on pin 8. The red LED uses about 1.9 V, leaving 3.1 V across the 330 Ω resistor. Ohm's law: 3.1 ÷ 330 ≈ 9.4 mA. The gauge shows that current leaving the pin.
The ATmega328P datasheet sets an absolute maximum of 40 mA per pin and 200 mA through its power pins. Past that the chip can be damaged. Outputs are only tested up to 20 mA, so plan to stay below that.
Now a 12 V LED strip rated 3 W. It needs 3 ÷ 12 = 0.25 A, or 250 mA. That is over six times the 40 mA limit, and the pin gives only 5 V. Wired directly, it could damage the pin.
A transistor carries the load
The fix: an N-channel MOSFET, a transistor used as a switch. Ours is an IRLZ44N. A voltage on its gate (G) opens a path from drain (D) to source (S). The Hardware lesson on transistors shows how.
The strip sits between the 12 V supply and the drain; the source goes to ground. Its 250 mA loops supply, strip, transistor, ground, and never passes through the pin. All grounds are joined, so both sides agree on 0 V.
Switching it from code
digitalWrite(9, HIGH) puts 5 V on the gate through a 220 Ω resistor. For a few microseconds current flows to charge the gate, at most 5 ÷ 220 ≈ 23 mA. Then it falls to under 0.0001 mA.
5 V is well above the gate's 1 to 2 V threshold, so the channel opens, to at most 0.025 Ω. 250 mA flows and the strip lights. The transistor drops only about 6 mV and turns under 2 mW into heat.
digitalWrite(9, LOW) drains the gate back to 0 V through the resistor. The channel closes, the 250 mA stops and the strip goes dark. The pin switched a 3 W load while giving almost no steady current.
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.