Electronics
Semiconductors — diodes, transistors, and MOSFETs
Everything in Passive Components only resists, stores, or releases energy. Semiconductors are where electronics gets interesting — a material that can be switched between conducting and not conducting is what makes diodes, transistors, and ultimately every digital chip possible.
- What it is
- Materials (and devices built from them) whose conductivity can be controlled — a diode conducts one way only, a transistor uses a small signal to control a much larger one.
- Mental model
- A diode is a one-way valve. A transistor is a valve controlled by a second, smaller input — current for a BJT, voltage for a MOSFET.
- Key numbers
- Silicon diode forward drop ≈ 0.7 V; MOSFET is voltage-controlled (near-zero static gate current), BJT is current-controlled.
- Reach for it when
- Anything that needs to switch or amplify — driving a motor/LED/relay from a microcontroller pin almost always means a transistor.
Conductors, insulators, and semiconductors
| Material class | Behavior | Example |
|---|---|---|
| Conductor | Electrons move freely — low resistance | Copper, aluminum |
| Insulator | Electrons are tightly bound — very high resistance | Glass, rubber, plastic |
| Semiconductor | In between — and its conductivity can be deliberately controlled | Silicon, germanium |
The trick that makes semiconductors useful isn't the raw material — pure silicon is a mediocre insulator — it's doping: adding trace impurities that create either a surplus of free electrons (N-type) or a surplus of "holes" where an electron is missing (P-type). Every diode and transistor below is built from junctions between N-type and P-type silicon.
Diode
A diode is a single P-N junction: current flows easily one way (forward biased) and is blocked the other way (reverse biased), up to some breakdown voltage where it fails or (for a Zener diode, deliberately) conducts in reverse at a controlled voltage.
An LED (light-emitting diode) is a diode engineered to emit light when forward biased — exactly the LED wired up in Fundamentals. A regular diode is also what makes the flyback protection on an inductive load work: wired backward across the load, it blocks current in normal operation and only conducts to absorb the collapsing field's reverse spike.
Diode types: why pick one over another
"Diode" isn't one part — different junction designs trade forward drop, speed, and behavior for different jobs:
| Type | Forward drop | Why you'd choose it |
|---|---|---|
| Standard rectifier | ~0.7 V | Cheap, general-purpose — AC-to-DC rectification, flyback protection, reverse-polarity protection. |
| Schottky | ~0.2–0.3 V | Lower forward drop (less wasted power/heat) and much faster switching — the default choice in switching power supplies and anywhere efficiency matters. |
| Zener | Reverse breakdown at a precise, chosen voltage | Deliberately operated in reverse breakdown to hold a node at a known voltage — the classic simple (if inefficient) voltage reference or crude regulator. |
| LED | ~1.8–3.3 V (varies by color) | Engineered to emit light when forward biased — the higher, color-dependent forward drop is a side effect of the semiconductor band gap that produces that specific wavelength. |
The "why" behind Schottky's speed and lower drop is the same underlying idea as everything else here: a Schottky diode uses a metal-semiconductor junction instead of a P-N junction, which stores far less charge at the junction and can therefore switch off almost instantly — exactly why it's preferred over a standard rectifier anywhere switching speed or efficiency actually matters, at the cost of a lower reverse voltage rating and more reverse leakage current.
Transistor — a controlled valve
A transistor is a three-terminal device where a small signal on one terminal controls a much larger current between the other two — either as a switch (fully on or fully off) or an amplifier (a small varying input becomes a larger varying output). Two families dominate: BJTs (Bipolar Junction Transistors, controlled by current) and FETs (Field-Effect Transistors, controlled by voltage) — MOSFETs are by far the most common FET.
BJT: current-controlled
A BJT has three terminals — Base, Collector, and Emitter. A small current flowing into the base allows a much larger current to flow from collector to emitter (NPN) — the ratio between them is the transistor's current gain, often called β or hFE, commonly in the range of tens to a few hundred. Because it's current-controlled, driving a BJT means supplying real base current, which a microcontroller pin can usually do directly for small transistors, but the base current still has to be sized correctly with a resistor.
NPN is by far the more common polarity for switching — the collector current flows into the collector and out the emitter toward ground, matching the low-side switching pattern used throughout this page. PNP is the mirror image (current flows out of the emitter), used for high-side switching — turning a load on by connecting it to the positive supply rail rather than ground — a real but less common pattern.
Worked example: sizing a base resistor
Say a 3.3 V GPIO pin needs to switch an NPN BJT hard on to sink 100 mA through a load, and the transistor's datasheet guarantees hFE ≥ 100 at that collector current. Sizing the base resistor is a direct application of the ratio above:
- Minimum base current for full saturation: IB = IC / hFE = 100 mA / 100 = 1 mA.
- Add margin — real designs drive well past the bare minimum to guarantee saturation across temperature and part variation; a common rule of thumb is 5–10× the calculated minimum, so target IB ≈ 5 mA.
- Solve for the resistor: Rbase = (VGPIO − VBE) / IB = (3.3 V − 0.7 V) / 5 mA = 520 Ω → the nearest standard value, 470 Ω, is the practical choice.
Every number in that calculation is doing real work: too little base current and the transistor sits in its linear region instead of fully saturated, wasting power as heat inside the transistor itself instead of delivering it to the load; too little resistance and excess base current does nothing useful beyond what saturation already achieved, just wasting power in the resistor and stressing the GPIO pin's output current rating for no benefit.
MOSFET: voltage-controlled
A MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor) has three terminals — Gate, Drain, and Source. The gate is electrically insulated from the rest of the device by a thin oxide layer (literally what "metal-oxide" describes) — so a MOSFET is controlled by voltage, not current, and draws essentially zero static current into its gate. Enough gate-to-source voltage (above a threshold, VGS(th)) opens a conductive channel between drain and source; below it, the channel is closed.
- N-channel
- Turns on with a positive gate voltage — by far the more common type for switching a load to ground (low-side switching).
- RDS(on)
- The channel's resistance once fully on — directly sets how much power the MOSFET itself dissipates as heat at a given current (P = I² × RDS(on)).
- Logic-level MOSFET
- Specifically rated to fully turn on from 3.3 V or 5 V logic — a "standard" MOSFET may need 10 V+ on the gate to reach its rated RDS(on), which a microcontroller pin can't supply on its own.
Wiring a MOSFET as a switch
This is the single most common way an embedded engineer touches a MOSFET: using it to let a low-power microcontroller pin switch a higher-current or higher-voltage load it could never drive directly.
With the GPIO pin high, gate voltage exceeds VGS(th), the channel opens, and current flows from the +12 V rail through the motor, through the MOSFET, to ground. Drive the pin low and the channel closes — the motor stops.
BJT vs. MOSFET
| BJT | MOSFET | |
|---|---|---|
| Controlled by | Base current | Gate voltage |
| Static control-input current | Real, must be sized with a resistor | ~Zero once at steady state |
| Switching speed | Moderate | Generally faster — good for PWM |
| Typical embedded use | Simple low-current switching, some analog/audio | Motor/LED/relay driving, switching power supplies |
Reach for a MOSFET by default for anything a microcontroller switches — the near-zero static gate current means no ongoing power cost to hold it on, and it handles higher currents and faster PWM more gracefully. Reach for a BJT when the load is genuinely small, when a design already has a base-current budget worked out, or in analog/audio applications where a BJT's more predictable linear-region behavior is actually the point rather than something to avoid.
Real-world applications
- Motor and relay drivers — the low-side MOSFET switch above is close to the default circuit for letting a microcontroller control anything drawing more current than a GPIO pin can supply.
- PWM LED dimming — a MOSFET switching fast enough (paired with PWM) controls LED brightness by varying on-time rather than current directly.
- Switching power supplies (buck/boost converters) — the MOSFET is the actual switch rapidly connecting and disconnecting the inductor described in Passive Components.
- Rectifier bridges — four diodes arranged in a bridge convert AC to pulsating DC, the first stage of nearly every mains power supply.
- Reverse-polarity and ESD protection — a diode placed across a power input can protect a whole board from a battery connected backward.
Gotchas
- A MOSFET gate left floating (e.g. a GPIO pin in high-impedance mode during MCU reset/boot) can drift to an unpredictable voltage and partially turn the MOSFET on — a pull-down resistor from gate to source is standard practice specifically to guarantee "off" by default.
- Driving a "standard" (non-logic-level) MOSFET directly from 3.3 V logic can leave it only partially on — high RDS(on) at partial drive means real, sometimes surprising, heat.
- A MOSFET's gate oxide layer is thin enough to be genuinely ESD-sensitive — anti-static handling isn't just a formality for these parts.
- Skipping the flyback diode on an inductive load (see Passive Components) is one of the most common ways to destroy a switching MOSFET or BJT.