When makers and engineers refer to a logic gate transistor, they are usually talking about one of two things: using discrete small-signal transistors to build basic Resistor-Transistor Logic (RTL) gates from scratch, or using a transistor as a logic-level switch to interface a 3.3V/5V microcontroller GPIO pin to a higher-voltage load. In both scenarios, you need components that switch fast, tolerate standard logic voltages, and are cheap enough to keep in your bench drawer by the handful.
The safest, most universal default part numbers for the job are the 2N3904 (NPN BJT) for 5V RTL logic and the 2N7000 (N-Channel MOSFET) for modern 3.3V/5V logic-level switching. Below is the practical bench guide to selecting, biasing, building with, and testing these discrete logic workhorses.
The Best Default Logic Gate Transistors for the Bench
While you can build logic gates out of almost any small-signal transistor, hunting down obscure part numbers wastes time. The TO-92 packaged parts listed below are the industry-standard defaults. They cost pennies, are available from every major distributor, and have well-documented characteristics.
| Part Number | Type | Max Vds / Vceo | Max Id / Ic | Logic Threshold (Vgs-th / Vbe) | Best Use Case |
|---|---|---|---|---|---|
| 2N3904 | NPN BJT | 40V | 200mA | ~0.7V (Vbe) | 5V RTL gates, driving 5V relays |
| 2N7000 | N-Ch MOSFET | 60V | 200mA | 0.8V - 3.0V (Vgs-th) | 3.3V/5V logic switching, NMOS gates |
| BS170 | N-Ch MOSFET | 60V | 500mA | 0.8V - 3.0V (Vgs-th) | Higher current 3.3V logic loads |
Operation Regions and Biasing for Logic Switching
To use a transistor as a logic gate or a digital switch, you must force it to operate exclusively in two regions: Cutoff (fully OFF, representing a logic 0 or open circuit) and Saturation/Ohmic (fully ON, representing a logic 1 or closed switch). You must actively avoid the Active/Linear region, where the transistor acts as an amplifier. Lingering in the linear region causes undefined logic voltages, slow switching times, and excessive heat dissipation.
| Region | BJT (2N3904) State | MOSFET (2N7000) State | Target for Logic? |
|---|---|---|---|
| Cutoff | Vbe < 0.6V, Ic ≈ 0mA | Vgs < 2.0V, Id ≈ 0mA | YES (Logic LOW / Open) |
| Active / Linear | Vbe ≈ 0.7V, Vce > 0.3V | Vgs > Vth, Vds > Vgs-Vth | NO (Causes heat & slow edges) |
| Saturation / Ohmic | Vbe ≈ 0.7V, Vce < 0.2V | Vgs >> Vth, Vds ≈ 0V | YES (Logic HIGH / Closed) |
How to Bias for Hard Saturation
For a BJT like the 2N3904, you cannot just apply 5V to the base; you need a base resistor to limit current and force saturation. If your load requires 20mA (Ic) and the transistor has a minimum hFE (gain) of 100, the theoretical base current (Ib) is 0.2mA. However, to guarantee saturation across temperature variations, we use an overdrive factor of 5x to 10x. Target Ib = 1mA to 2mA.
Calculation: Rb = (Vlogic - Vbe) / Ib = (5V - 0.7V) / 0.002A = 2,150Ω. A standard 2.2kΩ or 1kΩ base resistor is the perfect default for 5V logic driving a 2N3904.
For a MOSFET like the 2N7000, the gate draws virtually zero steady-state current. You bias it by applying a voltage well above its Vgs(th) threshold. A 5V or 3.3V GPIO pin directly drives the gate, but you should include a 100Ω to 220Ω gate stopper resistor in series to dampen high-frequency ringing, and a 10kΩ pull-down resistor from gate to ground to keep it off during microcontroller boot-up.
Building a Discrete NMOS NAND Gate (Application Circuit)
Let's build a functional 2-input NAND gate using discrete logic gate transistors. While RTL (using BJTs) naturally forms NOR gates, NMOS logic (using MOSFETs) naturally forms NAND gates. This circuit operates perfectly on a 5V supply and can drive standard 74HC logic inputs.
Component List
- Q1, Q2: 2N7000 N-Channel MOSFETs
- R1 (Pull-up): 10kΩ resistor
- R2, R3 (Gate Stoppers): 100Ω resistors
- R4, R5 (Gate Pull-downs): 10kΩ resistors
Pinout and Wiring Steps
Hold the 2N7000 with the flat face pointing toward you and the pins pointing down. From left to right, the pins are Source (S), Gate (G), and Drain (D).
- Establish the Pull-up: Connect one end of the 10kΩ pull-up resistor (R1) to the 5V VDD rail. Connect the other end to the Drain pin of Q1.
- Stack the Transistors: Connect the Source pin of Q1 directly to the Drain pin of Q2. This series connection is what creates the AND logic condition.
- Ground the Bottom FET: Connect the Source pin of Q2 to the system Ground (GND).
- Wire the Inputs: Connect Input A through a 100Ω stopper resistor (R2) to the Gate of Q1. Connect Input B through a 100Ω stopper resistor (R3) to the Gate of Q2. Add 10kΩ pull-down resistors from each gate to GND to prevent floating inputs.
- Take the Output: The logic output is taken from the junction of the 10kΩ pull-up resistor and the Drain of Q1.
Logic Verification: If either Input A or Input B is LOW (0V), its respective MOSFET turns off, breaking the path to ground. The 10kΩ pull-up resistor pulls the output HIGH (near 5V). Only when both Input A and Input B are HIGH (5V) do both transistors turn on, creating a low-resistance path to ground and pulling the output LOW (near 0V). This is a perfect NAND truth table.
Failure Modes and Multimeter Diagnostics
Transistors in logic circuits rarely fail from overcurrent unless you accidentally wire the output directly to VDD or GND. The most common failures are gate punch-through on MOSFETs (caused by ESD or exceeding the ±20V Vgs limit) and thermal runaway on BJTs (caused by operating in the linear region with high current).
Testing a BJT (2N3904) with a Multimeter
Set your multimeter to Diode Test mode.
- Place the Red probe on the Base and the Black probe on the Emitter. You should read a forward voltage drop of 0.55V to 0.75V.
- Move the Black probe to the Collector. You should read a similar 0.55V to 0.75V drop.
- Reverse the probes (Black on Base, Red on Emitter/Collector). The meter should read OL (Over Limit), indicating the junctions are blocking reverse current.
- If you read a short (0.00V) or an open (OL) in both directions on any junction, the transistor is dead.
Testing a MOSFET (2N7000) with a Multimeter
MOSFETs require a different technique because the gate is capacitively isolated. Set your meter to Diode Test mode or Continuity mode.
- Discharge the gate by touching the Black probe to the Source and the Red probe to the Gate simultaneously.
- Keep the Black probe on the Source. Touch the Red probe to the Drain. It should read OL (the internal body diode is reverse-biased, and the channel is off).
- Charge the gate: While keeping the Black probe on the Source, touch the Red probe to the Gate. The meter's internal battery (usually 3V to 9V) will charge the gate capacitance, turning the MOSFET on.
- Move the Red probe back to the Drain. The meter should now beep or read near 0.0V, indicating the channel is conducting.
- Touch the Black probe to the Gate to discharge it. The Drain-Source path should immediately return to OL.
Frequently Asked Questions
Can I use a 2N2222 instead of a 2N3904 for logic gate circuits?
Yes, but it is generally overkill. The 2N2222 is rated for 800mA, making it better suited for driving motors or high-power LEDs. For pure logic gate construction or switching small signals, the 2N3904 (200mA) is preferred because it has lower internal capacitance, resulting in faster switching speeds and sharper logic edges. According to ON Semiconductor's 2N3904 datasheet, its transition frequency (fT) is typically 300MHz, making it highly responsive for discrete logic applications.
Why does my logic gate transistor get hot when switching a 5V signal?
If your transistor is hot to the touch, it is lingering in the Active/Linear region instead of hitting hard Saturation. For a BJT, this means your base resistor is too large, starving the base of current. For a MOSFET, it means your gate drive voltage is too close to the Vgs(th) threshold, causing the Rds(on) resistance to remain high. Lower your base resistor value (e.g., from 10kΩ to 2.2kΩ) or ensure your MOSFET gate is seeing a full, clean 5V or 3.3V logic HIGH.
How do I interface a 3.3V ESP32 GPIO to a 5V logic gate transistor?
The easiest method is to use a logic-level MOSFET like the 2N7000 or BS170. As detailed in All About Circuits' guide on MOSFET switching, these specific FETs have a Vgs(th) well below 2.5V, meaning a 3.3V ESP32 GPIO pin will fully enhance the channel and switch the 5V load without needing a dedicated level-shifter IC. Just ensure you include a 10kΩ pull-down resistor on the gate so the load doesn't turn on while the ESP32 is booting and its pins are floating.






