Using a Transistor as a Switch: Base Resistors, Gain & Saturation
A microcontroller GPIO pin can safely supply only 10–20 mA, which is enough for a single indicator LED but nowhere near enough for a relay coil, buzzer, or DC motor. A single NPN bipolar junction transistor (BJT) solves that problem by using a tiny base current to switch a much larger collector-to-emitter load current.
Explore Electronics 101 & its website →
Design rules apply to common small-signal NPN transistors (such as 2N2222 or BC547) in low-side switching circuits, paired with NavSprout’s Electronics 101 transistor lessons.
Cutoff, active, and saturation: why switches avoid the middle
When using a transistor as a digital switch, you want it either completely OFF (cutoff) or completely ON (saturation). Leaving a transistor halfway on in its linear active region forces it to drop significant voltage while carrying load current, turning wasted power (P = V_CE × I_C) directly into heat.
| Operating region | Base-emitter state | Collector-emitter state | Role in a switch circuit |
|---|---|---|---|
| Cutoff (OFF) | V_BE < ~0.6 V, I_B = 0 | Open path, I_C ≈ 0 | Load is completely off; near-zero heat |
| Active (Linear) | Small I_B, I_C = β × I_B | Large V_CE drop across transistor | Used for amplifiers; avoid for switching |
| Saturation (ON) | Strong I_B (forced β ≈ 10–20) | V_CE(sat) ≈ 0.1–0.3 V | Load gets nearly full supply; minimal heat |
How to size the base resistor reliably
- Find your load current I_C (for example, 100 mA for a small 5 V relay coil).
- Use a conservative forced gain of 10 to 20 rather than the datasheet’s maximum hFE so the transistor is guaranteed to saturate: I_B ≈ 100 mA / 10 = 10 mA (or 5 mA at forced gain 20).
- Subtract the ~0.7 V base-emitter drop from your control voltage (for 3.3 V ESP32 logic: 3.3 V − 0.7 V = 2.6 V; for 5 V Arduino: 4.3 V).
- Apply Ohm’s law: R_base = 2.6 V / 0.005 A = 520 Ω, so pick a standard 470 Ω resistor.
- If switching an inductive load like a relay or motor, always place a flyback diode (such as 1N4007) in reverse across the coil to absorb turn-off voltage spikes.
Common questions
Why do I need a base resistor at all?
The base-emitter junction behaves like a forward-biased diode. Without a resistor to limit current, driving the base directly from 3.3 V or 5 V can draw excessive current and destroy either the transistor or the microcontroller pin.
When should I choose a MOSFET instead of a BJT?
For loads above ~300–500 mA or battery-powered designs, a logic-level N-channel MOSFET is usually more efficient because its gate draws virtually zero steady-state current and its on-resistance (R_DS(on)) wastes less voltage.
Does the load go on the collector or emitter side of an NPN switch?
Place the load between the positive supply and the collector, and tie the emitter directly to ground (low-side switching). Putting the load on the emitter causes the emitter voltage to rise and prevents clean saturation.
Sources & editorial method
Written by NavSprout Editorial. Published and checked .
Report a correction →