# The transistor

*A switch you control with a voltage*

A transistor is a switch you control with a voltage: a small voltage on its gate decides whether current can flow through it. Every logic gate, and ultimately a whole CPU, is built from these voltage-controlled switches.

Group: Fundamentals
URL: https://digiwleea.wleeaf.dev/learn/transistor/

> **KEY:** This is page one, so there is nothing to recall yet. By the end of the course every part on this page will have stacked up into a small **8-bit computer** you build and run yourself. It all starts with one component: the transistor.

A transistor is a switch. Instead of flipping it with a finger, a **voltage on its gate** decides whether it conducts. That one idea, repeated a few billion times, is what a computer is. Two flavors of switch do all the work in this course:

- **NMOS** conducts (closes) when its gate sees a `1`, and is open when the gate sees a `0`.
- **PMOS** is the mirror image: it conducts when its gate sees a `0`. It is drawn with a small bubble on the gate to remind you it is the inverted one.

Each transistor has three pins: the **gate** (`G`, the control) and two **channel** pins. When it conducts, the two channel pins are connected and a signal can pass between them; when it does not, they are isolated and nothing passes. The gate itself never lets current through to the channel: it only steers, like the handle of a valve.

> **TIP:** A concrete picture: think of a transistor as a **garden-hose tap**. Water (the signal) wants to flow between the two channel pins, and the gate is the tap handle. For an NMOS, turning the handle to `1` opens the tap and water flows; `0` shuts it. A PMOS is a tap plumbed in reverse, open at `0`. Crucially, your hand on the handle does not get wet: the gate controls the flow without joining it.

_Circuit diagram: One NMOS passing A through to F only while EN (its gate) is 1. Press Open in lab to flip EN yourself and watch the channel open and close._

**Q (Predict, then check):** In the switch circuit above, `A` is held at `1` and `EN` is the gate of a single NMOS feeding `F`. What does the probe at `F` read when `EN = 0`? When `EN = 1`?

**A:** With `EN = 0` the NMOS is open, so nothing drives `F`: it reads `Z` (floating, **not** `0`). With `EN = 1` the channel closes and `A`'s `1` reaches `F`, so it reads `1`. Open the lab and flip `EN` to see exactly this.

> **KEY:** That is the whole foundation. A `1` or `0` on a gate opens or closes a path, and by arranging these switches between power (`VCC`) and ground (`GND`) you can compute anything at all. Curious what is actually inside the switch? Watch one turn on, step by step, in the [interactive MOSFET simulator](https://digiwleea.wleeaf.dev/tools/mosfet-simulator/).

## Why two kinds?

Having a switch that closes on `1` (NMOS) **and** one that closes on `0` (PMOS) is what lets a gate always drive its output firmly. Whatever the inputs do, you can arrange for one kind to be pulling while the other is letting go. The next lesson on [signals](https://digiwleea.wleeaf.dev/learn/signals/) shows why that matters, and [Complementary CMOS](https://digiwleea.wleeaf.dev/learn/cmos/) turns the pair into your first gate.

One subtlety to internalize early: a wire that no closed transistor is driving is not `0`, it is **floating** (`Z`). Telling those two apart is the very next lesson, and it will save you hours of debugging later.

### FAQ

**Q:** What is a transistor?

**A:** A transistor is a switch you control with a voltage: a small voltage on its gate decides whether current can flow between its two channel pins. Every logic gate, and ultimately a whole CPU, is built from these voltage-controlled switches.

**Q:** When does an NMOS transistor conduct?

**A:** An NMOS conducts (closes) when its gate sees a `1`, and is open when the gate sees a `0`. While it conducts, its two channel pins are connected and a signal can pass between them.

**Q:** What is the difference between an NMOS and a PMOS transistor?

**A:** They close on opposite gate values. An NMOS conducts when its gate is `1`; a PMOS is the mirror image and conducts when its gate is `0` (it is drawn with a small bubble on the gate to mark the inversion). Having both is what lets a [CMOS](https://digiwleea.wleeaf.dev/learn/cmos/) gate always drive its output firmly.

**Q:** Does current flow through the gate of a transistor?

**A:** No. The gate only steers, like the handle of a valve: it decides whether the two channel pins connect, but current never passes through the gate itself into the channel.
