In the transistor as a switch article we used an NPN. But you'll also find PNP in circuits, and many people get confused: when is it this one and when that one? The answer lies in where the load is.
The difference inside
A transistor is three semiconductor layers: in the NPN a thin P layer (the base) sits between two N layers, and in the PNP the reverse. The practical result:
- In the NPN, current enters at the collector and leaves at the emitter, and it turns on with current flowing into the base.
- In the PNP, current enters at the emitter and leaves at the collector, and it turns on with current flowing out of the base.
How to remember it from the symbol? The arrow on the emitter points in the direction of current. In the NPN the arrow points outwards (Not Pointing iN), and in the PNP it points inwards (Pointing iN Proudly). See circuit symbols.
NPN: a switch on the ground side (low-side)
- The emitter to ground.
- The load between the supply and the collector.
- Base HIGH (through a resistor) → the transistor conducts and the load turns on.
- Examples: 2N2222, BC547 and 2N3904.
This is the easiest and most common with a microcontroller, because the signal swings from 0 to 5 or 3.3, and the emitter is at zero.
Another advantage: the load can be at a higher voltage than the microcontroller (for example a 12 V relay) with no problem, because the base only sees the emitter at zero.
PNP: a switch on the supply side (high-side)
- The emitter to the supply (+).
- The load between the collector and ground.
- Base LOW → the transistor conducts.
- Base HIGH (at the same voltage as the emitter) → it turns off.
- Examples: 2N2907, BC557 and 2N3906.
Why would I need a PNP at all?
Sometimes the load's ground must stay connected at all times:
- A module or sensor whose supply you want to cut to save battery, with its ground shared with the rest of the circuit.
- Driving a column in a 7-segment display or an LED matrix.
- Loads whose ground is the chassis (as in cars).
Why can't an NPN be used for the sensor? If you cut the ground of an I2C module with an NPN, the module is still connected to the Arduino through the SDA and SCL wires, so the current finds another path to ground through the signal pins, and the module half-works or is damaged. Cutting the supply itself is cleaner.
The code in both cases
// NPN: HIGH = on
digitalWrite(7, HIGH); // load ON
digitalWrite(7, LOW); // load OFF
// PNP (same voltage as the Arduino): LOW = on
digitalWrite(8, LOW); // load ON
digitalWrite(8, HIGH); // load OFF
Note: with the PNP, the pin is an INPUT (floating) during boot until the code runs, so the load may come on for a moment. Put a pull-up between the base and emitter so it stays off until the code decides.
The trap: the load voltage is higher than the microcontroller's
You have a PNP with its emitter at 12 V, and the Arduino outputs only 5 V:
- A base at 5 V = 7 V below the emitter → the transistor will stay on permanently!
- And the Arduino pin will also receive voltage from the 12.
The fix: a small NPN controlling the PNP's base:
- The Arduino → a resistor → the base of the NPN.
- The NPN's collector → a resistor → the base of the PNP.
- A pull-up resistor (for example 10k) between the PNP's base and its emitter, so it turns off properly.
Exactly the same idea with a P-channel MOSFET for higher currents. See reverse polarity protection and the logic-level MOSFET.
In numbers
A 200 mA load at 12 V with a PNP (2N2907):
- The PNP's base current = 200 ÷ 10 = 20 mA.
- Its base resistor = (12 − 0.7) ÷ 0.02 ≈ 565 → 560 Ω. (The NPN pulls the other end to ground.)
- The NPN carries that 20 mA, so its base needs about 2 mA: (5 − 0.7) ÷ 0.002 ≈ 2150 → 2.2k.
- And the 10k between the PNP's base and the 12 V.
The logic here isn't inverted: Arduino HIGH → the NPN turns on → it pulls the PNP's base down → the load turns on.
Calculating the base resistor (in both cases)
Ib ≈ Ic ÷ 10
Rb = (V_control − 0.7) ÷ Ib
Dividing by 10 (instead of the hFE) ensures the transistor is well saturated. Calculate with the Ohm's law calculator.
Identify the type with a multimeter
Set the multimeter to diode mode and look for the base: the pin that conducts to the other two in one direction (about 0.6–0.7).
- If the red lead is on the base and a reading appears for both pins → NPN.
- If the black lead is on the base → PNP.
And of the other two pins, the emitter usually reads slightly higher than the collector. See using the multimeter.
Summary
| NPN | PNP | |
|---|---|---|
| Position | Ground side | Supply side |
| Turns on when the base is | 0.7 above the emitter | 0.7 below the emitter |
| From a microcontroller | Directly | Directly if the same voltage, otherwise via an NPN |
| Best-known part numbers | 2N2222 and BC547 | 2N2907 and BC557 |
The pin order (E, B and C) varies between types, even in the same package. Always check the datasheet.
What about the MOSFET?
Exactly the same story: N-channel for the ground side and P-channel for the supply side. The difference is that a MOSFET is controlled by voltage, not current, and heats up less at high currents. For loads above about 500 mA, a MOSFET is usually better. See what is a MOSFET.
FAQ
What if I fit an NPN in place of a PNP in the circuit? It won't work properly, and the load may stay permanently on or off. And the pins are often in a different order too, so check before swapping.
Is the PNP more expensive or weaker? At the same size, the PNP is usually a little slower with a lower hFE, and a P MOSFET has higher resistance than an N. That's why designers prefer N where possible.