Home / Circuit lab / Transistor switch

Transistor switch simulator

A microcontroller pin can't power a motor or a lamp, but it can switch a transistor that does. Choose the base resistor and the load, and find out when the transistor is properly on.

Intermediate

input pin

Controls

Readings

What's going on

The input pin pushes a small current into the base: Ib = (Vin − 0.7 V) ÷ Rb. The transistor then lets up to hFE × Ib flow from collector to emitter. If that's more than the load can draw, the transistor is saturated: fully on, with only about 0.2 V across it, so it stays cool. If not, it's in the active region, acting like a variable resistor and turning the difference into heat.

Because hFE varies a lot between transistors and with temperature, designers don't rely on it. A common rule is a forced beta of 10 to 20: give the base a tenth to a twentieth of the load current, which saturates the transistor whatever its actual gain.

Our guide to transistors as switches covers this in more depth, including MOSFETs and flyback diodes for motors and relays.

How this simulation works

This uses the standard simplified switch model: a fixed base-emitter voltage of 0.7 V, a fixed collector-emitter saturation voltage of 0.2 V, and a constant hFE. Real transistors are more gradual, and the onsemi P2N2222A datasheet gives a maximum Vce(sat) of 0.3 V at 150 mA. The power and current warnings use the P2N2222A's ratings: 625 mW at 25 °C and 600 mA continuous collector current.

Keep exploring