Logic & Circuits
Series/parallel, binary, logic gates, and the transistor.
Logic & Circuits
Counting, logic gates, and the transistor
Navigate with ← → or Space · F to present fullscreen · N for the script
Lesson notes
How loads combine, how computers count in binary, the six logic gates and their truth tables, two-way switching, and the transistor — the switch behind all of it.
Logic & Circuits
Counting, logic gates, and the transistor
- Series & parallel connections
- Number systems: binary, hex, decimal
- Boolean algebra & logic gates
- Truth tables & simplification
- Two-way switching
- Transistors & the transistor switch
- The fuse
Series & Parallel Loads
Two ways to connect loads
Series: same current, voltages add, resistances add. Parallel: same voltage, currents add, resistance drops.
Christmas-light analogy: old series strings — one bulb out, all out. Parallel — each independent.
Combining resistors
Series: R = R₁ + R₂ | Parallel: 1/R = 1/R₁ + 1/R₂
- Series — resistance increases
- Parallel — resistance decreases below the smallest
Example: Two 100 Ω in parallel = 50 Ω. Two 100 Ω in series = 200 Ω.
Number Systems
Binary, decimal, and hexadecimal
Computers think in binary; hex is shorthand for humans.
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0x0 |
| 5 | 0101 | 0x5 |
| 10 | 1010 | 0xA |
| 15 | 1111 | 0xF |
| 255 | 11111111 | 0xFF |
A bit = one 0/1. 8 bits = 1 byte = 0–255. One hex digit = exactly 4 bits (a nibble).
The vocabulary
Why it matters for embedded work:
- Bit — a single 0 or 1 — the smallest unit
- Byte — 8 bits, holds 0–255 — one character or one register
- Hex (0x..) — compact way to write bytes — registers and colors use it
- Binary place values — 128 64 32 16 8 4 2 1 — add the 1s to convert
Boolean Algebra & Gates
The six logic gates
Logic gates take 0/1 inputs and produce a 0/1 output.
- AND: Output 1 only if ALL inputs are 1. (A·B)
- OR: Output 1 if ANY input is 1. (A+B)
- NOT: Inverts the input. 1→0, 0→1. (Ā)
- NAND: AND then inverted. The "universal" gate — builds any logic.
- NOR: OR then inverted. Also universal.
- XOR: Output 1 if inputs DIFFER. The heart of addition.
Truth tables for 2 inputs
Every possible input combination and its output.
| A | B | AND | OR | XOR | NAND |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Simplification saves gates
Fewer gates = cheaper, faster, less power.
- Identity laws — A·1 = A, A+0 = A
- Null laws — A·0 = 0, A+1 = 1
- De Morgan’s — NOT(A·B) = Ā + B̄ — swap AND/OR and invert
- Karnaugh maps — a visual grid to spot the simplest expression
Two-Way Switching
Two switches, one light — controlled from either end.
The staircase circuit: two SPDT switches wired so flipping EITHER one toggles the lamp. Electrically this is the XOR function in the physical world.
Great real-world hook: this is literally the wiring in every staircase and hallway.
Transistors
NPN vs PNP basics
A transistor is a current-controlled switch/amplifier with three legs: Base, Collector, Emitter.
NPN
- Turns ON when Base is HIGH
- Emitter goes to GND
- Most common for low-side switching
PNP
- Turns ON when Base is LOW
- Emitter goes to +V
- Used for high-side switching
Transistor as a switch
A tiny base current lets a large collector current flow — so a 5 mA MCU pin can switch a 500 mA motor or relay.
Always add a base resistor (~1 kΩ) to limit base current, and a flyback diode across inductive loads.
A real transistor
A common small-signal transistor in a TO-92 plastic package — three legs: Base, Collector, Emitter.
- Flat side helps identify the pin order
- Check the datasheet — pinouts vary
- e.g. 2N2222 (NPN), BC547, S8050
Building Logic Gates from Transistors
A logic gate is just transistors wired as switches.
Every AND, OR, and NOT inside a chip is built from transistors. A pull-up resistor holds the output HIGH; transistors pull it LOW when their inputs turn them on. Wire them differently → different logic.
This is the bridge from "transistor = switch" to "computers are made of these". Millions to billions on one chip.
NOT gate — one transistor (inverter)
The simplest gate: input HIGH turns the transistor on, dragging the output LOW. Input LOW leaves the output pulled HIGH. The output is always the opposite of the input.
- Input HIGH → transistor ON → OUT = 0
- Input LOW → transistor OFF → OUT = 1
- Pull-up resistor sets the default HIGH
Watch the input toggle and the output flip to the opposite.
NOR gate — two transistors in parallel
Put two transistors side by side. If EITHER input is HIGH, that transistor pulls the output LOW. The output is only HIGH when both inputs are LOW — that is NOR (NOT-OR).
- Either input HIGH → OUT = 0
- Both inputs LOW → OUT = 1
- Add an inverter on the output → OR gate
Cycles through 00, 01, 10, 11 — output only lights green at 00.
NAND gate — two transistors in series
Stack two transistors in a chain. Current only reaches ground when BOTH are on, so the output is only pulled LOW when both inputs are HIGH — that is NAND (NOT-AND).
- Both inputs HIGH → OUT = 0
- Any input LOW → OUT = 1
- Add an inverter → AND gate
NAND is "universal" — you can build every other gate from NANDs alone.
The pattern: wiring sets the logic
- 1 transistor: Inverter — output is the opposite of the input.
- 2 parallel: Either input ON pulls output LOW. + inverter → OR.
- 2 series: Both inputs ON to pull output LOW. + inverter → AND.
AND = NAND + NOT · OR = NOR + NOT. NAND and NOR are universal building blocks.
The Fuse
A fuse is a deliberate weak link.
It is a thin wire rated for a maximum current. If too much current flows (a short or fault), it melts and breaks the circuit — protecting everything downstream from fire or damage.
Pair this with the short-circuit warning from Day 2. Fuses are the safety net.
Day 3 — Key Takeaways
- Series adds resistance; parallel reduces it
- Computers count in binary; hex is 4 bits per digit
- Six gates — AND/OR/NOT/NAND/NOR/XOR — build all logic
- Truth tables define a gate; algebra simplifies it
- A transistor lets a small signal switch a big load
- A fuse sacrifices itself to protect the circuit