Introduction
A transistor is a simple component used to build many useful circuits. This article explains how transistors work so you can apply them in later circuit designs.
Once you understand the basics, transistors are fairly straightforward. This article focuses on the two most common types: BJT and MOSFET.
Transistors operate like electronic switches that open and close current flow. An easy way to think about a transistor is as a switch without moving parts. Like a relay, it can turn things on or off. Transistors can also be partially on, which is useful for amplifier design.
1. How a BJT Works
Let’s start with the classic NPN transistor.
A bipolar junction transistor (BJT) has three pins:
- Base (B)
- Collector (C)
- Emitter (E)

If you switch it on, current can flow from the collector to the emitter. When it is off, no current flows. In the example circuit below, the transistor is off, so no current flows and the LED is off.

To turn the transistor on, the voltage between the base and emitter must be around 0.7 V.
If you had a 0.7 V battery you could connect it between base and emitter to turn the transistor on. Since we usually do not have a 0.7 V battery, how do we turn the transistor on? The base-emitter junction behaves like a diode with a forward voltage, which will clamp that portion of voltage. If you place a resistor in series, the remaining voltage drops across the resistor. By adding a resistor, you will automatically obtain roughly 0.7 V across the base-emitter junction. This is the same idea as using a resistor to limit current through an LED. Adding a push button allows you to control the transistor and therefore the LED:

1.1 Choosing Component Values
To choose component values, it helps to know how the transistor works: when current flows from base to emitter, the transistor turns on and allows a larger current from collector to emitter.

The ratio between these two currents is the transistor's gain. For general-purpose transistors like the BC547 or 2N3904, the gain may be around 100. That means 0.1 mA into the base can allow about 10 mA from collector to emitter.
What resistor R1 gives 0.1 mA base current? If the battery is 9 V and the base-emitter reaches 0.7 V, there will be 8.3 V across the resistor. Use Ohm’s law:

So you need an 83 kΩ resistor. A standard value such as 82 kΩ is sufficient. R2 limits current through the LED and can be the same value you would use if the LED and resistor were connected directly to the 9 V battery. For example, 1 kΩ should work for typical LEDs.
1.2 Choosing a Transistor
NPN transistors are the most common BJTs. PNP transistors work the same way but with all currents reversed. When selecting a transistor, the most important parameter is how much current the transistor can handle, called the collector current (I_C).
2. How a MOSFET Works
MOSFETs are another common transistor type. They have three pins:
- Gate (G)
- Source (S)
- Drain (D)

MOSFETs operate similarly to BJTs but with one important difference:
For a BJT, the current into the base controls how much current flows from collector to emitter.
For a MOSFET, the voltage between gate and source controls how much current can flow from drain to source.
2.1 How to Turn On a MOSFET
Here is a circuit example to turn on a MOSFET.

To turn on a MOSFET you need the gate-to-source voltage (V_GS) to be higher than the transistor's threshold voltage. For example, the BS170 has a V_GS(th) of about 2.1 V (see the datasheet). The threshold voltage is essentially the voltage at which the MOSFET starts to turn off, so to fully turn it on you need a voltage somewhat higher than the threshold. How much higher depends on the current you want (the datasheet specifies the relationship). Being a few volts above threshold is usually enough for low-current loads such as an LED. Note that being able to allow 1 A does not guarantee 1 A will flow; the rest of the circuit determines the actual current. Also make sure you do not exceed the maximum gate-source voltage rating (the BS170 is 20 V). In the example above, pressing the button connects the gate to 9 V and turns the MOSFET on.
2.2 Choosing Component Values
The exact value of R1 is not critical; about 10 kΩ is typical and its purpose is to pull the MOSFET gate low so the transistor is off. R2 sets the LED current; 1 kΩ works for most LEDs. Q1 can be almost any N-channel MOSFET, for instance the BS170.
2.3 How to Turn Off a MOSFET
An important characteristic of MOSFETs is that the gate-to-source structure behaves like a capacitor. When you apply a voltage between gate and source, that voltage remains until it is discharged.

Without a pull-down resistor such as R1 in the example, the MOSFET may not turn off. With R1 present, the gate-source capacitance has a discharge path that returns the MOSFET to the off state.
2.4 Choosing a MOSFET
N-channel and P-channel MOSFETs operate similarly but with current in opposite directions; a P-channel MOSFET requires a negative gate-to-source voltage relative to its source to turn on. There are thousands of MOSFETs to choose from. If you want a concrete suggestion for simple circuits, BS170 and IRF510 are commonly used. When selecting a MOSFET, remember two key parameters:
- Gate-source threshold voltage (V_GS(th)). You need sufficient gate voltage to turn the MOSFET on.
- Continuous drain current. This is the maximum current the MOSFET can pass.
Other parameters may be important depending on the application, but the two above are a good starting point.
2.5 MOSFET Gate Current
If you are driving a MOSFET from a microcontroller such as a microcontroller, Arduino, or Raspberry Pi, remember there is current into the gate when the MOSFET is first switched on. Because the gate behaves like a capacitor, once charged there is no steady-state gate current. However, during the brief charging interval a surge of current may flow. To protect the microcontroller, add a gate resistor:

A typical value is 1 kΩ, though you should calculate the best value for your specific case using Ohm’s law.
3. Why Use Transistors
Why not simply connect an LED and resistor directly to a battery? Transistors let a small current or voltage control a larger current or voltage. This is useful when controlling devices such as motors, high-power LEDs, speakers, relays, and more from a Raspberry Pi, Arduino, or microcontroller. Those boards usually supply only a few milliamps at 5 V from their I/O pins, so you cannot directly drive, for example, a 110 V outdoor light from a pin.
Instead you can use a relay. Even relays usually require more current than a pin can provide, so a transistor is needed to drive the relay:

Transistors are also useful in simpler sensor circuits such as light sensors, touch sensors, or H-bridge circuits. They are used in almost all electronics and are among the most important components in electronics.
4. Transistors as Amplifiers
Transistors are the basis of amplifiers. They do not just have two states (on/off); they can operate at any point between fully on and fully off. A small signal with little energy can control the transistor to produce a larger signal at the collector-emitter or drain-source output, allowing signal amplification. The simple amplifier below drives a speaker: as the input voltage increases, base-emitter current increases and the speaker current increases accordingly.
