the transistor as a switch
/ tran-ZIS-ter /
Imagine a tiny faucet for electricity. A normal faucet has a knob you turn by hand; this one has a third terminal that turns it on or off using nothing but a voltage. Put a high voltage on that control terminal and current can flow through; put a low voltage there and the flow stops. A transistor is exactly this: an electrically controlled switch, with no moving parts, that one signal can flick on or off billions of times a second. Because the controlling thing is itself just a voltage, the output of one transistor can drive the control of the next — and that chaining is the whole secret of building a computer.
The kind used in modern chips is the MOSFET (metal-oxide-semiconductor field-effect transistor). It has three terminals: source, drain, and a gate (the control). In the most common picture, when the gate voltage crosses a threshold the path between source and drain becomes conducting (the switch is closed, on); below the threshold it is non-conducting (open, off). Chips pair two complementary flavours — an n-type transistor that turns on with a high gate voltage and a p-type that turns on with a low one — in an arrangement called CMOS (complementary MOS). The trick of CMOS is that for a steady output, exactly one of the pair is on, so almost no current flows straight from power to ground; power is spent mainly during the brief moment of switching.
Honest caveat: 'on' and 'off' are an idealization. A real transistor does not snap perfectly between a clean 1 and a clean 0 — it has a smooth analog response, leaks a little current even when 'off', takes a small but nonzero time to switch, and dissipates heat. Digital logic works because we deliberately stay away from the murky middle voltages and let the design restore signals toward the two clean extremes. The whole tower of computing — gates, adders, processors — rests on treating this messy analog device as a clean switch, which is a remarkably good but not perfect approximation.
A CMOS inverter is two transistors: a p-type on top and an n-type below, gates tied together as the input, the joint between them as the output. Input low (0): the top p-type is on, the bottom n-type is off, so the output is pulled up to high (1). Input high (1): they swap, and the output is pulled down to low (0). Out always equals 'not in' — the simplest gate, the NOT gate.
Two switches in series-and-parallel already make a logic gate: this is how a 1 becomes a 0.
A transistor is not a tiny mechanical relay you can hear click — there is nothing moving. It is a region of specially treated silicon whose ability to conduct is reshaped by the electric field from the gate, which is why it is called a field-effect transistor.