The transistor as a switch — letting a tiny signal control a big current.
In Lesson 4 we learned a pin can't power hungry
things directly. This lesson is the fix, and it's one of the most useful ideas in all of electronics:
a transistor lets a weak control signal switch a much larger current. It's the bridge
to relays, motors, and bright lights — the "output" muscle of your gadget.
The one win
You understand the transistor-as-a-switch: a small current at the control terminal turns a big
current on and off — and you know the one extra part (a diode) that protects everything.
A transistor is an electrically-controlled valve
Back to the water analogy. A transistor is a valve in a big pipe, opened
by a small control input. A little signal at the base (the control terminal)
lets a large flow pass between the other two terminals
(SparkFun: Transistors).
"Low-side" switch: the pin drives the transistor's base through a resistor; the
transistor connects the load to ground when told to. The load gets its own supply.
Pin → base, through a resistor. The base needs only a small current; a
~1 kΩ resistor protects the pin. (Like the LED, the base can't limit its own current.)
The load gets its own power. The transistor just opens/closes the path to ground.
Pin HIGH → transistor on → load runs. Pin LOW → off.
Common ground. The transistor's emitter and your board share GND (Lesson 4's
golden rule).
BJT vs MOSFET — the two-second version
You'll see two families. A BJT (e.g. the classic 2N2222) is fine for small
loads. A MOSFET (e.g. a "logic-level" one) handles bigger currents more
efficiently and is the modern default for motors and LED strips. For now: both are switches; pick a
MOSFET when the load is hungry.
The must-have part for coils & motors: the flyback diode
Anything with a coil — a motor, a relay — stores energy in a magnetic field. When you switch it
off, that energy snaps back as a brief high-voltage spike that can destroy your transistor.
Rule you must not skip
When switching a motor or relay coil, place a flyback diode across the
coil (backwards to normal current) to absorb that spike. Without it, you'll kill transistors. Most
ready-made relay modules already include it — one reason we'll prefer them next lesson.
Check yourself
Recall first.
Read this next (primary source)SparkFun — Transistors,
especially the "as a switch" section. It extends the same water-valve picture we used here.
I'm your teacher — ask me anything. Tell me the load you want to switch (its voltage
and current) and I'll help you pick a transistor and whether you need a flyback diode.