Transistors

Transistors are the electronic switches that let a low-power control signal — from an Arduino GPIO pin, an ESP32 output, a 555 timer, or a simple…

Read full description & FAQ ↓

6 Items

Transistors are the electronic switches that let a low-power control signal — from an Arduino GPIO pin, an ESP32 output, a 555 timer, or a simple push button — turn on and off loads that draw far more current than the controller can supply directly. In LED projects, transistors are used to switch entire arrays of LEDs, drive high-power LEDs at currents above what a microcontroller pin can source, implement PWM dimming for smooth brightness control, and build darlington pairs for even higher current gain. We stock two families of bipolar junction transistors (BJTs): PNP transistors and NPN transistors. Each type has a distinct role in circuit design, and understanding when to use which is the key to building reliable LED switching circuits.

NPN transistors are the most commonly used type in hobby LED projects. In an NPN switching circuit, the transistor sits between the LED load and ground (low-side switching). The Arduino or ESP32 GPIO pin connects to the transistor's base through a base resistor, and when the GPIO pin goes HIGH, current flows into the base, which turns on the transistor and allows current to flow from the collector (connected to the LED load) to the emitter (connected to ground). When the GPIO pin goes LOW, the transistor turns off and the LEDs go dark. This is the standard configuration for Arduino LED control tutorials, LED matrix multiplexing, and any project where a microcontroller needs to switch more LEDs or higher current than its GPIO pins can handle directly. A typical Arduino Uno GPIO pin can source or sink 20–40mA — enough for one or two LEDs. With an NPN transistor, that same pin can control an LED array drawing 500mA or more.

PNP transistors operate in the opposite configuration: high-side switching. The PNP transistor sits between the positive supply voltage and the LED load. When the base is pulled LOW (relative to the emitter), the transistor turns on and passes current from the supply to the load. PNP transistors are used when you need to switch the positive side of a load while keeping the ground side common — useful in circuits where multiple LED groups share a common ground bus but need independent positive-side control, and in certain circuit topologies where the load must connect to ground rather than to the positive rail. PNP switching is less common in basic Arduino projects but appears frequently in H-bridge motor drivers, bidirectional LED circuits, and complementary push-pull output stages.

How BJTs work in LED circuits: A bipolar junction transistor has three terminals: base, collector, and emitter. A small current flowing into the base (for NPN) or out of the base (for PNP) controls a much larger current flowing between the collector and emitter. The ratio of collector current to base current is the transistor's current gain (hFE or β), typically ranging from 100 to 300 for general-purpose BJTs. To fully turn on (saturate) a BJT as a switch, you drive the base with enough current that the transistor passes the full load current with minimal voltage drop across the collector-emitter junction (VCE(sat), typically 0.2–0.3V). The base resistor limits the base current to a safe level and is calculated based on the supply voltage, the base-emitter voltage drop (VBE ≈ 0.7V for silicon BJTs), and the desired base current. A common rule of thumb is to design for a base current that is 1/10th of the collector current to ensure full saturation.

PWM dimming with transistors: One of the most popular uses for transistors in LED projects is pulse-width modulation (PWM) dimming. Instead of applying a steady current to the LEDs, the microcontroller rapidly switches the transistor on and off at a frequency high enough that the human eye cannot perceive the switching (typically 500Hz or higher). By varying the duty cycle — the percentage of time the transistor is on versus off — the perceived brightness of the LEDs changes smoothly from fully off (0% duty) to fully on (100% duty). Arduino's analogWrite() function generates a PWM signal on certain GPIO pins, and when that pin drives a transistor's base through a resistor, the transistor switches the full LED array at the PWM frequency. The LEDs dim smoothly without any change in forward current during the “on” portion of each cycle, so the LED color temperature stays consistent across the dimming range — unlike analog dimming, which shifts LED color as current decreases.

Darlington pairs use two transistors in cascade to achieve very high current gain. The emitter of the first transistor drives the base of the second, and the combined current gain is the product of the two individual gains — typically 10,000 or more. This means a tiny base current (a few microamps) can switch a large collector current (hundreds of milliamps). Darlington pairs are useful when driving high-current LED loads from logic outputs with very limited source current capability, or when controlling motors, solenoids, and relays from GPIO pins. Dedicated darlington pair ICs like the ULN2003 and ULN2803 integrate multiple darlington transistor channels with built-in base resistors and flyback diodes, making them convenient for switching multiple LED groups or motors from a single IC package.

Common LED projects using transistors: Transistors appear in model railroad layouts (switching building interior LEDs, crossing signals, and block detection circuits from DCC decoder outputs), automotive LED installations (driving LED arrays from 12V vehicle systems with dimming capability), escape room and prop builds (triggering LED effects from sensor inputs through an Arduino), Christmas and holiday displays (sequencing large LED arrays with PWM fade effects), guitar pedal circuits (LED indicator switching and signal clipping stages), and arcade cabinet projects (button illumination and marquee LED control). For complete LED circuit design, pair transistors with current-limiting resistors on each LED (use our LED Resistor Calculator to find the right value), component LEDs for the emitters, and decoupling capacitors on any microcontrollers in the circuit. If your power source is AC (landscape transformer, DCC track power), convert to DC first with a bridge rectifier and smoothing capacitor before connecting to the transistor switching circuit.

Frequently Asked Questions

NPN transistors turn on when current flows into the base and are used for low-side switching — the transistor sits between the load and ground. PNP transistors turn on when current flows out of the base and are used for high-side switching — the transistor sits between the positive supply and the load. NPN is the more common choice for Arduino and microcontroller-driven LED circuits because the GPIO pin goes HIGH to turn on the load, which is the more intuitive behavior. PNP is used when you need to switch the positive side of the circuit.
Yes — always. The base-emitter junction of a BJT behaves like a diode with a ~0.7V forward voltage drop. Without a base resistor, connecting a 5V GPIO pin directly to the base would cause excessive current to flow through the base-emitter junction, potentially damaging both the transistor and the microcontroller pin. A typical base resistor value for switching an LED array is 1KΩ to 10KΩ. The exact value depends on the load current and the transistor’s current gain (hFE), but 1KΩ works well for most standard LED switching circuits driven from a 5V Arduino pin.
Yes, for one or two standard 20mA LEDs. An Arduino Uno GPIO pin can source or sink up to about 40mA (with a recommended limit of 20mA per pin). For a single LED with a current-limiting resistor, that is sufficient. But if you need to drive three or more LEDs, high-brightness LEDs, or an LED array drawing 100mA+, you need a transistor. The GPIO pin drives the transistor base with a few milliamps, and the transistor switches the full load current from the main power supply. This protects the microcontroller from overcurrent damage.
A darlington pair is two transistors connected in cascade so that the first transistor drives the second. The combined current gain is the product of the two individual gains — typically 10,000 or more, compared to 100–300 for a single transistor. You need a darlington pair when your control signal can only provide a very small base current (a few microamps) but you need to switch a large load current (hundreds of milliamps). Dedicated darlington array ICs like the ULN2003 and ULN2803 integrate multiple darlington channels with built-in base resistors and flyback diodes, making them convenient for driving multiple LED groups, motors, or relays from microcontroller outputs.
Connect the Arduino’s PWM-capable GPIO pin to the transistor base through a 1KΩ base resistor. The LED array (with its own current-limiting resistors) connects from the positive supply to the transistor’s collector, and the emitter goes to ground. Use analogWrite(pin, value) where value is 0–255 (0 = off, 255 = full brightness). The Arduino generates a PWM signal at ~490Hz or ~980Hz (depending on the pin), which switches the transistor on and off too fast for the eye to see. The LEDs appear to dim smoothly as you change the duty cycle.
For most hobby LED projects, a BJT is simpler and more than adequate. BJTs are easy to drive from Arduino GPIO pins with a base resistor, widely available, inexpensive, and well-documented in beginner tutorials. MOSFETs are better for very high current loads (multiple amps), very fast switching frequencies, or situations where you need the switching element to draw essentially zero current from the control pin. For standard LED arrays drawing up to about 500mA with PWM dimming at Arduino frequencies, a general-purpose NPN BJT like the 2N2222 or 2N3904 is the simplest, most reliable choice.