The transistor, explained simply

A transistor is an electrically controlled switch or amplifier. Learn how to drive a motor or a high-power LED from an Arduino.

Ic = β × Ib · Rb = (Vctrl − 0.7) / Ib

How does it work?

A bipolar transistor has three legs: base, collector, emitter. A small base current allows a much larger collector-emitter current, multiplied by the gain β (often 100 to 300).

NPN, PNP and MOSFET

The NPN (2N2222, BC547) switches the ground side: the easiest with an Arduino. The PNP switches the + side. The MOSFET (IRLZ44N) is voltage-driven, runs cool and handles high currents: ideal for motors and LED strips.

Sizing the base resistor

To switch 200 mA with β = 100 you need 2 mA of base current; use 2–5× more to saturate. From 5 V: (5 − 0.7) / 0.01 ≈ 430 Ω → 470 Ω. A 1 kΩ suits most small loads.

The flyback diode

With a motor or relay, add a reverse diode (1N4007) across the coil: it absorbs the voltage spike at turn-off that would otherwise destroy the transistor.

Drive a motor through a transistor in the simulator and measure the current with the ammeter.

Try it free

FAQ

Why not wire a motor straight to the Arduino?

A pin supplies 20–40 mA at most. A motor needs hundreds: the transistor sits in between.

How do I identify the legs?

Check the datasheet: the E-B-C order varies with model and package (TO-92, TO-220).