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 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.