Electricity/Transistors and switching/NPN and PNP

NPN and PNP

There are two kinds of transistor, made from the same silicon in the opposite order. One turns on when you drive its base high and the other when you pull it low, and choosing the wrong one gives you a circuit that will not switch off.

Everything so far has been an NPN. Swap the silicon over — p-type, n-type, p-type — and you get a PNP, which does the same job with every direction reversed.

Flip between them.

Two flavours, one changed ingredient
npn · n-p-n
An NPN turns on when its base is about 0.7 V above its emitter. The emitter goes to ground, the arrow points out of the part, and you turn it on by pushing current into the base — which means driving the base high. This is the one you will use ninety per cent of the time.

The arrow is the whole difference

Both symbols are a bar with three leads. The arrow is on the emitter in both, and it points the way conventional current goes through that leg.

  • NPN: the arrow points out of the part. Current leaves at the emitter, so the emitter goes towards ground.
  • PNP: the arrow points in. Current enters at the emitter, so the emitter goes towards the positive rail.

That is why a PNP is drawn upside down relative to an NPN. It is not a different convention, it is the same convention with the emitter at the end the current arrives from.

What each one needs on its base

An NPN turns on when its base is about 0.7 V above its emitter, and its emitter is at 0 V. So: drive the base high.

A PNP turns on when its base is about 0.7 V below its emitter, and its emitter is at the supply. So: pull the base low.

Both still need a base resistor, and both are still sized the same way — a tenth to a twentieth of the load current, as in a transistor as a switch.

Under the load, or over it

Below the load, or above it
npn · low side · pin low
Circuit
Pin
Across the 1 kΩ
0 V
Base current
0
Lamp
dark
Pin low, lamp dark. No base current, so no collector current. An NPN with its base at the same voltage as its emitter is off, and it stays off — which is exactly what a pin that has not booted yet gives you.

The NPN sits between the load and ground. The load's positive end stays wired to the supply the whole time and the transistor makes or breaks its path to ground. That is low-side switching, and it is what you should reach for unless you have a reason not to.

The PNP sits between the supply and the load, so the load's ground stays connected and the transistor makes or breaks the supply. That is high-side switching, and the reasons to want it are specific: a load whose ground is shared with something else, a sensor you want to leave properly earthed, or anything where a floating ground would be a problem.

The trap, and it is a common one

Set the figure to the PNP and put the pin high. The lamp stays lit.

A 3.3 V pin cannot turn off a PNP whose emitter is on 5 V. Off means the base is pulled up to the emitter, and the highest the pin can reach is 3.3 V, which leaves 1.7 V still forward biasing the junction. The transistor never switches off, the code looks correct, and nothing measures wrong except the thing you were trying to control.

Three ways out:

  • Run the load from 3.3 V as well, so the pin can reach the emitter.
  • Drive the base with something that can actually pull up to 5 V.
  • Put a small NPN in front of it, base to the pin, collector to the PNP's base. The NPN pulls the PNP's base down when the pin goes high; a resistor to 5 V pulls it back up when the pin goes low. Two transistors, and the pin only ever has to reach 0.7 V.

Which one to buy

They come in pairs, and the pairs are deliberate — same package, same ratings, opposite polarity. A 2N3904 is NPN and a 2N3906 is its PNP. A BC547 pairs with a BC557, an S8050 with an S8550.

If you have no reason to prefer one, use the NPN. It is the one every tutorial assumes, it is driven the way a GPIO pin naturally wants to drive, and for the same part number and price it is usually the slightly better transistor — electrons move through silicon more easily than holes do, which is a fact about the material and not something a manufacturer can design around.

Edit this page — content/fundamentals/electricity/npn-and-pnp.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Fundamentals on the forum