Skip to content

Embedded Systems

How to switch a big load from an Arduino with a transistor

An Arduino pin can give only about 20 mA, so to run a lamp, motor or relay, let the pin switch a transistor and let the supply carry the load. In the usual NPN low-side switch, the load goes from the supply to the transistor's collector, the emitter goes to GND, and the pin feeds the base through a resistor. A few milliamps into the base lets hundreds flow through the load.

How much the pin gives

The base drops about 0.7 V, like a diode. Through 1 kΩ from a 5 V pin:

IB = 5 − 0.7 V over 1 kΩ = 4.3 mA

A small NPN with a gain of 150 could then pass up to 4.3 mA × 150 ≈ 645 mA. A 100 Ω lamp on 5 V wants only about 48 mA, so it gets all of it, and the transistor is saturated: fully on, with only a few tenths of a volt across it. The pin supplies just the base's 4.3 mA. The lamp's current never touches it.

Live experiment

Starved or fed

Pip is a 100 Ω lamp, fed from the 5 V rail through an NPN with a gain of 150, its base driven from pin 9 through R2. Try 100 kΩ: 43 µA in, 6.4 mA out, a dim, warm half-on. Try 1 kΩ: the lamp takes its full current, about 48 mA. Then hang the lamp straight from the pin.

Try it yourself: free lesson

“Switch a bigger load” is lesson 5 of 6 in Signal Shore, Embedded Systems World 3. Free with an account. Lessons unlock in order, so you’ll do the 18 before it first.

Feed the base enough

The gain sets a ceiling, not the current. If the base gets too little, the ceiling drops below what the load wants. Through 100 kΩ, the base gets 43 µA, and 43 µA × 150 ≈ 6.4 mA is all the lamp can have: it glows dimly while the transistor sits half on, dropping volts and getting warm.

So size the base current for the load, with margin:

  1. Find the minimum: load current ÷ gain. For 48 mA at a gain of 150, that's 0.32 mA.
  2. Give it several times more, so the transistor saturates even with a low-gain part. Designers often aim for a tenth of the load current.
  3. Work out the resistor: R = (5 − 0.7) ÷ IB, and keep IB under the pin's 20 mA.

The code doesn't change

digitalWrite(9, HIGH);   // base fed: load on
digitalWrite(9, LOW);    // base empty: load off

The same two lines that light an LED now switch the lamp, a relay or a small motor. The transistor even works with analogWrite for PWM speed or brightness control.

Separate supplies, one ground

A motor is best fed from its own supply, not the Arduino's 5 V pin. Tie that supply's − to the Arduino's GND, so the base current has a path home through the emitter.

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

“Switch a bigger load” is lesson 5 of 6 in Signal Shore, Embedded Systems World 3. Free with an account. Lessons unlock in order, so you’ll do the 18 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 3Why not run a 500 mA motor straight from a board pin?
    Show the answer

    Answer: A pin can only give about 20 mA safely; the motor would damage it. A pin is a tiny switch. The transistor is a big one the pin can control.

    • Why not “It would work fine”? It wouldn't: the pin would be pushed far past its 40 mA damage limit, and the motor would barely turn.
    • Why not “The motor is too fast”? Speed has nothing to do with it. The motor would try to draw 500 mA through a pin rated for 20.
    • Why not “Pins only do 5 V”? Plenty of small motors run on 5 V. The problem is current: 500 mA is 25 times what a pin can safely give.
  2. Question 2 of 3With the lamp on the transistor, what does the program write to pin 9 to light it?
    Show the answer

    Answer: HIGH, exactly as if the LED were on the pin. The pin only feeds the base. HIGH puts about 4 mA into it, the transistor switches on, and the lamp draws its 48 mA from the 5 V rail. The code doesn't change; the circuit does.

    • Why not “LOW: the transistor inverts it”? In this low-side NPN switch, HIGH on the base turns the transistor on. LOW leaves the base with no current, so the lamp is off.
    • Why not “analogWrite(9, 48)”? analogWrite sets a PWM duty from 0 to 255, not a current. A value of 48 would switch the lamp on only about a fifth of the time.
    • Why not “A current of 48 mA”? Code can't write a current; it sets the pin HIGH or LOW. The lamp's 48 mA comes from the 5 V rail through the transistor.
  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 the ceiling the gain allows, not what flows. A lamp that can only take 48 mA gets 48 mA.
    • Why not “150 mA”? 150 mA would come from a 1 mA base current. Here the lamp itself limits the current to 48 mA.
    • Why not “4.3 mA”? 4.3 mA is the base current. The collector carries far more: as much as the lamp wants, up to the gain's ceiling.
Keep practising: free lesson

“Switch a bigger load” is lesson 5 of 6 in Signal Shore, Embedded Systems World 3. Free with an account. Lessons unlock in order, so you’ll do the 18 before it first.

Questions people ask

What base resistor should I use with an Arduino and an NPN transistor?

Work out the base current you need, the load current divided by the gain, then supply several times more so the transistor saturates. R = (5 − 0.7) ÷ I_B. For loads up to a couple of hundred milliamps, 1 kΩ (about 4.3 mA) is a common choice.

Do I need a diode across a motor or relay?

Yes. A coil keeps its current flowing for a moment when the transistor switches off, and with nowhere to go it makes a voltage spike that can destroy the transistor. A diode across the coil, its stripe towards the + supply, gives that current a safe path.

Should I use a transistor or a MOSFET with an Arduino?

For small loads either works. For hundreds of milliamps or more, a logic-level MOSFET is usually better: its gate takes no steady current, and when fully on it drops far less voltage than a BJT, so it runs cooler.

Every topic