Use this transistor switch calculator to find the base resistor for an NPN transistor, when you want to turn on a load like a motor, a lamp or a relay from an Arduino pin or a switch.

The load current that can flow through the transistor is the base current times the gain of the transistor. So first find the base current you need, then use Ohm’s law to find the resistor:

Fill in the input voltage, the current your load needs, and the gain of your transistor:

Input Voltage (from the pin or switch)
V
Load Current (IC)
Transistor Gain (hFE or β, use the minimum from the datasheet)
×
Base-Emitter Voltage (VBE)
V
Safety Factor (extra base current)
Base current needed (IB)
-
Base resistor value (RB)
-
Nearest standard resistor (E12, next lower)
-
Base current with that resistor
-
Power in the transistor (about)
-
Input 5 VRB1.2 kΩIB = 3.58 mAQ1+VLoadIC = 100 mA

Why a Safety Factor?

The gain of a transistor varies a lot from one transistor to the next, and it drops at higher currents. If the base current is too low, the transistor doesn’t turn fully on. Then the load gets less current than it should, and the transistor gets hot.

So it’s a good idea to give the transistor a few times more base current than the minimum. The calculator uses 3× by default. And it picks the nearest standard resistor that is lower than the calculated value, which gives a little more base current.

If you drive an inductive load like a motor or a relay, remember the diode across the load.

Want to learn more? Check out the transistor as a switch, or read how transistors work.