Build a transistor: the MOSFET, one level below the switch
Everywhere else on digiwleea a transistor is just a switch. Here is why, one step at a time: a transistor is a switch you flip with a voltage, and this shows exactly how.
Press Next to walk through it, then try it yourself. A transistor is really a gap that a voltage can bridge with electrons, closing a circuit and lighting a lamp.
The real physics, one layer deeper
The walkthrough kept it simple; here is what is actually happening in the silicon. The two ends, source and drain, are islands of n-type silicon (rich in free electrons) sitting in a body of p-type silicon, whose free charges are positive "holes". On top sits a metal gate, separated from the silicon by a paper-thin oxide insulator, which is why no current ever flows into the gate; it works purely by its electric field.
Put a positive voltage on the gate and its field reaches through the oxide into the p-silicon. A small voltage just pushes the holes away, leaving a bare depletion region with still no path across. But past the threshold (about 1 V) the field is strong enough to pull a thin sheet of electrons up to the surface. That inversion layer is the "bridge" from the walkthrough, a brand-new n-type channel connecting the two islands. Remove the gate voltage and it vanishes: a voltage-controlled switch, with no moving parts. Wire a few of these switches together and you get logic gates: build them in the logic gate simulator.
Why it "saturates"
There is one more wrinkle, beyond this simulator. Once current is flowing, the drain end of the channel feels less of the gate's pull (its own voltage fights it), so the channel is thinner there. Raise the drain voltage enough and the channel pinches off at the drain, and the current stops climbing. That flat region is why a transistor also makes a decent current source and amplifier, but for logic we only care that it is a clean ON/OFF switch, which is exactly what you controlled above.
Common questions
How does a MOSFET work?
A MOSFET works by the field effect. A voltage on its insulated gate creates an electric field that reaches into the silicon and pulls charge carriers to the surface, forming a conducting channel between the source and drain. Because the gate sits on an insulator, no current flows into it; it switches the transistor purely with its field.
What is the threshold voltage?
The threshold voltage (Vth) is the gate voltage at which a channel first forms. Below it the transistor is off (cutoff); above it the channel conducts. For logic transistors it is typically a few tenths of a volt up to about 1 V.
What is the difference between NMOS and PMOS?
An NMOS turns on when its gate is high (an electron channel forms in a p-type body); a PMOS turns on when its gate is low (a hole channel forms in an n-type body). CMOS logic pairs them so one is always off, which is why it draws almost no power while idle.
Why doesn't current flow into the gate?
The gate is separated from the silicon by a paper-thin oxide insulator, so it is electrically isolated from the channel and controls the transistor only through its electric field. That is why a MOSFET uses almost no current to hold its state.
What is pinch-off and saturation?
When the drain voltage rises above the gate overdrive (VG − Vth), the channel narrows to nothing at the drain end, called pinch-off. Past that point the drain current barely rises with more drain voltage; this flat region is the saturation region.