How to Build a Simple Transistor LED Switch
Introduction
Ever wanted to make an LED blink with just a push of a button?
In this post, we’ll explore how to use two kinds of transistors NPN and PNP to act as electronic switches for LEDs. You can follow along with just the parts in most beginner electronics kits.
Why Use a Transistor as a Switch?
A transistor is used for the following reasons: -
-
Control large currents with small currents (your button or microcontroller pin doesn’t need to handle the LED’s full load).
-
Act as an electronic gate (when a small base current flows, the transistor “connects” the LED to power or ground.)
-
Enable logic control
NPN Transistor Switch
How it works:
In an NPN transistor, current flows from the collector to the emitter only when there’s a small current into the base. This means we can connect the LED to +V through a resistor, and let the transistor connect it to ground.
Parts needed (from your collection):
-
1 × NPN transistor (e.g., 2N2222 or C945)
-
1 × LED
-
1 × Current limiting resistor (e.g., 330 Ω for a 5 V supply)
-
1 × Base resistor (e.g., 1 kΩ)
1 x Push button
-
Breadboard & wires
-
Power supply (5 V or 9 V)
Wiring:
Power Supply (+V to LED resistor)
The positive terminal of your power supply (e.g., 5 V) connects to one end of a 330 Ω resistor.
This resistor limits current so the LED doesn’t burn out.
LED Connection
The other end of the 330 Ω resistor connects to the anode (long lead) of the LED.
- The cathode (short lead) of the LED connects to the collector of the NPN transistor.
This means current must pass through the transistor to reach ground.
Emitter to Ground
The emitter pin of the NPN transistor connects directly to the ground (0 V) of the power supply.
This makes the transistor act like a “switch” between the LED and ground.
Base Resistor & Button
The base pin connects to one end of a 1 kΩ resistor.
The other end of that resistor goes to one terminal of the push button.
The other terminal of the push button goes to +V.
This ensures when the button is pressed, a small controlled current flows into the base
PNP Transistor Switch
How it works:
A PNP transistor works the opposite way: current flows from the emitter to the collector when the base is pulled low (more negative than the emitter). This means we can connect the emitter to +V, and the transistor will supply current to the LED when triggered.
Parts needed:
-
1 × PNP transistor (e.g., A1015 or S9012)
-
1 × LED
-
1 × Current limiting resistor (330 Ω)
-
1 × Base resistor (1 kΩ)
1 x Push button
-
Breadboard & wires
-
Power supply
Wiring:
Emitter to +V
The emitter of the PNP transistor connects directly to the positive supply voltage (e.g., 5 V)
In PNP mode, the emitter is the source of current.
Collector to LED Resistor
The collector pin connects to one end of a 330 Ω resistor.
The other end of the resistor connects to the anode of the LED.
The LED’s cathode connects directly to ground.
Base Resistor & Button
The base connects to one end of a 1 kΩ resistor.
The other end of this resistor connects to one terminal of the push button.
The other terminal of the button goes to ground.
Pressing the button pulls the base voltage lower than the emitter, which turns the transistor ON.
Operation:
Button unpressed → base is at +V (same as emitter) → transistor OFF → no current to LED.
Button pressed → base is pulled toward ground → transistor turns ON → emitter sends current to collector → LED lights.
NPN vs PNP — When to Use Which?
NPN (low-side): Easier for microcontrollers, common in switching to ground.
PNP (high-side): Useful when you want the load connected to ground and control the supply side.
NPN (low-side): Easier for microcontrollers, common in switching to ground.
PNP (high-side): Useful when you want the load connected to ground and control the supply side.
Important Notes:
-
Base resistor is essential to limit the base current and prevent damaging the transistor.
-
For a microcontroller control signal, connect it to the base via the resistor (instead of a button).
-
If using higher voltage supplies (>9 V), recalculate resistors for the LED to avoid burning it out.










