The Circuit Maker
Components10 min read

Transistors Explained: How They Work and How to Use Them

A transistor is a semiconductor device that switches or amplifies electrical signals. Learn how BJT and MOSFET transistors work, with pinouts, formulas, and beginner circuit examples.

·

A transistor is a semiconductor device that switches or amplifies electrical signals using three terminals. A small input signal at one terminal controls a much larger current between the other two. Transistors are the foundation of all modern electronics — every computer chip contains billions of them, and in hobby electronics they're used to let a microcontroller control motors, relays, LED strips, and other loads that draw more power than a pin can supply directly.

The two main types of transistors

For beginners, there are two transistor families you'll encounter:

PropertyBJTMOSFET
Full nameBipolar junction transistorMetal-oxide-semiconductor FET
Control methodCurrent-controlled (base current)Voltage-controlled (gate voltage)
PinsBase, Collector, EmitterGate, Drain, Source
Input impedanceLow (draws current)Very high (draws almost no current)
Best forSmall signals, simple switchingPower switching, high current loads
Common parts2N2222 (NPN), 2N3906 (PNP)IRLZ44N, IRF520 (N-channel)

BJT transistors

How a BJT works

A BJT has three layers of semiconductor material forming two junctions. The thin middle layer is the base. When a small current flows into the base, it allows a much larger current to flow from the collector to the emitter. The ratio of collector current to base current is called the current gain (β or hFE), typically 100–300 for common transistors.

I_collector = β × I_base

A 2N2222 with β = 200 needs only 0.1 mA of base current to switch 20 mA of collector current (enough for an LED). This is how an Arduino pin (which can provide ~20 mA) can control devices that need hundreds of milliamps.

NPN vs PNP

NPN is the most common type. Current flows from collector to emitter when the base voltage is about 0.7V above the emitter. The load connects between the positive supply and the collector; the emitter connects to ground.

PNP works in reverse — current flows from emitter to collector when the base is pulled about 0.7V below the emitter. PNP is used when you need to switch the high side of a circuit. For beginners, NPN is simpler and recommended.

BJT as a switch — example circuit

To drive a motor from an Arduino using a 2N2222 NPN transistor:

  1. Connect the motor between +12V and the collector of the 2N2222.
  2. Connect the emitter to ground.
  3. Connect the Arduino output pin to the base through a 1 kΩ resistor (the base resistor).
  4. Place a flyback diode (1N4007) across the motor, cathode to +12V, to protect against voltage spikes.

Calculating the base resistor:

If the motor draws 200 mA and the transistor's β is 200, you need at least 1 mA of base current (200 mA / 200). The Arduino supplies 5V; the base-emitter junction drops 0.7V. Using our Ohm's Law calculator:

R_base = (V_arduino - V_BE) / I_base = (5 - 0.7) / 0.001 = 4,300Ω

A 1 kΩ to 2.2 kΩ resistor provides enough base current with margin. Going lower wastes current; going too high may not fully saturate the transistor.

MOSFET transistors

How a MOSFET works

A MOSFET is controlled by voltage at the gate, not current. When the gate-source voltage (V_GS) exceeds the threshold voltage(typically 1–4V), the MOSFET turns on and allows current to flow from drain to source. Because the gate is insulated, it draws essentially zero continuous current — only a tiny pulse to charge the gate capacitance.

N-channel vs P-channel

N-channel MOSFETs are the equivalent of NPN — they switch the low side (between the load and ground). They turn on when the gate is pulled high. Most common in hobby electronics.

P-channel MOSFETs switch the high side (between power supply and the load). They turn on when the gate is pulled low relative to the source. Used for power switching and battery protection.

Logic-level MOSFETs

Standard MOSFETs may need 10V at the gate to fully turn on, which is too high for a 3.3V or 5V microcontroller. Logic-level MOSFETs (like the IRLZ44N or IRL540N) are designed to fully turn on at 3.3–5V gate voltage. Always check the datasheet for V_GS(th) — the threshold voltage — and choose a logic-level part when driving from Arduino.

MOSFET as a switch — example

To drive an LED strip from an Arduino using an IRLZ44N:

  1. Connect the LED strip's positive wire to +12V.
  2. Connect the LED strip's negative wire to the drain.
  3. Connect the source to ground.
  4. Connect the Arduino output pin to the gate through a 100–470Ω resistor.
  5. Add a 10 kΩ pull-down resistor between gate and source to ensure the MOSFET is off by default.

PWM on the Arduino pin gives you dimming control — the MOSFET switches fast enough to follow the PWM signal, varying the average power to the LED strip.

BJT vs MOSFET: which should you use?

ScenarioBest choiceWhy
Switching an LED from ArduinoBJT (2N2222)Simple, cheap, low current
Switching a DC motor (1A+)MOSFET (IRLZ44N)Lower heat, handles high current
LED strip dimming (PWM)MOSFETFast switching, low on-resistance
Driving a relay coilEitherBJT is simpler; MOSFET wastes less power
Audio amplifier stageBJTBetter linearity for analog signals
Battery-powered projectMOSFETNo continuous gate current saves power

Important transistor specifications

SpecificationWhat it meansExample (2N2222)
V_CE(max) or V_DS(max)Maximum voltage the transistor can block40V
I_C(max) or I_D(max)Maximum continuous current800 mA
β / hFE (BJT)Current gain (collector/base)100–300
V_GS(th) (MOSFET)Gate voltage needed to turn onN/A (BJT)
R_DS(on) (MOSFET)Resistance when fully on (lower = less heat)N/A (BJT)
P_D(max)Maximum power dissipation500 mW

Common mistakes with transistors

  • Forgetting the base resistor on a BJT. Without a resistor between the Arduino pin and the base, excessive base current can damage the Arduino pin or the transistor. Always use a 1 kΩ–10 kΩ base resistor.
  • Using a non-logic-level MOSFET with Arduino. A standard MOSFET (like IRF540) needs ~10V at the gate to fully turn on. At 5V, it's only partially on and gets hot. Use logic-level parts (IRLZ44N, IRL540N) for 5V or 3.3V logic.
  • No flyback diode on inductive loads. Motors, relays, and solenoids create voltage spikes when switched off. Without a diode across the load, these spikes can destroy the transistor. Always add a 1N4007 or similar diode.
  • Exceeding current or voltage limits. Check the datasheet for I_C(max) and V_CE(max). Exceeding either destroys the transistor, usually permanently.
  • Floating MOSFET gate. An unconnected MOSFET gate picks up static and can randomly turn on. Always use a pull-down resistor (10 kΩ) between gate and source.

Summary

Transistors are semiconductor switches controlled by a small signal. BJTs are current-controlled (base current drives collector current); MOSFETs are voltage-controlled (gate voltage switches drain-source current). NPN/N-channel are the most common types for low-side switching. Use BJTs for simple, low-current switching; use logic-level MOSFETs for high-current loads like motors and LED strips. Always include a base/gate resistor, use flyback diodes on inductive loads, and check the datasheet for voltage, current, and power limits.