Skip to content

Electronics

Transistor as a switch, explained

An NPN transistor works as a switch because a small current into its base lets a much bigger current flow from its collector to its emitter. No base current: the switch is open. Enough base current: it's closed, and the load gets nearly the whole supply. That's how a microcontroller pin, good for about 20 mA, switches lamps, relays and motors.

A trickle controls a flood

The ratio between the two currents is the current gain, β (beta):

IC = β × IB

β is a plain number, often 100–300, and it varies from part to part and with temperature. So designers use the smallest β on the datasheet. The base needs only IC ÷ β, which is why a small signal can switch a big load.

Live experiment

Turn the tap

A tiny current into an NPN transistor's base controls a 12 V lamp's current. Step the base current from 0 to 2 mA and watch the lamp's current, and how much heat the transistor makes on the way.

Try it yourself: free lesson

“Transistors as switches” is lesson 5 of 6 in Silicon Ridge, Electronics World 5. Free with an account. Lessons unlock in order, so you’ll do the 32 before it first.

Fully on or fully off

A switch should sit at one of two ends. In cutoff there's no base current and no collector current. In saturation the base has more current than the load needs, the load takes all the supply can push, and only a sliver, around 0.1–0.3 V, is left across the transistor. Either way the transistor wastes almost nothing, because heat is VCE × IC and one of the two is close to zero.

In between lies the active region, where IC ≈ β × IB. Amplifiers live there. A switch must not: with a 12 V, 120 Ω lamp half on, 6 V across the transistor and 50 mA through it make 0.3 W of heat.

Size the base resistor

The base-emitter junction drops about 0.7 V, like a diode, so the base always needs a resistor. Aim for 2 to 10 times the minimum base current:

RB = Vcontrol − 0.7 V over IB

Example: a 12 V LED strip draws 300 mA, β is at least 100, and the control is 5 V. The minimum is 3 mA, so aim for 6 mA:

RB ≤ 4.3 V over 0.006 A ≈ 717 Ω

Round down to 680 Ω: about 6.3 mA, 2.1 times the minimum.

++12 V5 VRB​loadQ1common ground
A low-side switch: the load sits above the collector, and both supplies share one ground

Low-side and common ground

Put the load between the supply and the collector, with the emitter to ground: a low-side switch. The base current returns through the emitter, so the control circuit and the load's supply must share a common ground. Put the load on the emitter instead and the emitter only follows the base, 0.7 V below it, so the load never gets the full supply.

For heavier loads, or a gate that takes no steady current, a MOSFET is often the better switch.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Transistors as switches” is lesson 5 of 6 in Silicon Ridge, Electronics World 5. Free with an account. Lessons unlock in order, so you’ll do the 32 before it first.

Or start from the very first lesson, no account needed

Work it out

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3In an NPN switch, the small control current flows into the…
    Show the answer

    Answer: base. The control current goes into the base and out of the emitter. The big load current flows from collector to emitter.

    • Why not “emitter”? In an NPN switch both currents leave through the emitter, which goes to ground. The control current goes in at the base.
    • Why not “collector”? The collector carries the big load current, which flows from collector to emitter. The small control current goes in at the base.
  2. Question 2 of 3A transistor lets a board pin…
    Show the answer

    Answer: Control a much bigger current than it could supply itself. Small base current, big collector current.

    • Why not “Read analog values”? Reading analog values is the job of the board's ADC, through analogRead. A transistor switch only turns a load on or off.
    • Why not “Store a bit”? Storing bits is what memory and flip-flops do. A switching transistor holds nothing: it follows the pin.
    • Why not “Run faster”? A transistor doesn't change how fast the board runs its program. It switches a load current on and off for the pin.
  3. Question 3 of 34.3 mA goes into the base of a transistor with a gain of 150. The lamp on its collector can only ever take 48 mA. How much flows through the lamp?
    Show the answer

    Answer: 48 mA: the load decides, the transistor is fully on. 4.3 × 150 is 645 mA, far more than the lamp can take, so the transistor switches fully on and the lamp takes its own 48 mA. The gain sets a ceiling, not the current.

    • Why not “645 mA”? 645 mA is base current times gain, the most the transistor would allow. The lamp's own resistance only lets 48 mA through, so that's all that flows.
    • Why not “150 mA”? 150 is the gain, a multiplier with no unit, not a current. Once the transistor is fully on, the lamp sets the current.
    • Why not “4.3 mA”? 4.3 mA is the base current, the small control current. The transistor lets far more flow from collector to emitter.
Keep practising: free lesson

“Transistors as switches” is lesson 5 of 6 in Silicon Ridge, Electronics World 5. Free with an account. Lessons unlock in order, so you’ll do the 32 before it first.

Questions people ask

How does a transistor work as a switch?

With no base current the transistor is off (cutoff) and no collector current flows. With enough base current it is fully on (saturated), with only a sliver, around 0.1–0.3 V, left across it, so the load gets almost the whole supply. A small control current into the base switches a much bigger load current.

What base resistor do I need for a transistor switch?

Find the minimum base current, I_load ÷ β_min, and aim for 2 to 10 times that so it saturates even with the weakest part. Then R_B = (V_control − 0.7 V) ÷ I_B, rounded down. For a 300 mA load, β of at least 100 and a 5 V signal, 680 Ω gives about 6.3 mA.

Why does my transistor get hot when used as a switch?

It's probably only half on, in its active region, with several volts across it while the load current flows. The heat is V_CE × I_C. Give the base more current, through a smaller base resistor, so it saturates and keeps only a sliver of voltage.

Every topic