Start Here: What Digital Logic Is
A computer does not understand numbers, words or pictures. It only knows whether each of billions of tiny switches is on or off. This volume explains how so little can do so much: what a digital signal is, why two values work better than ten, and how a small table of 0s and 1s can describe a whole circuit. It ends with your first logic circuit.
- What digital logic is, and where it hides inside everyday things
- The difference between an analogue and a digital signal
- Why computers use two values, not ten
- How to read a truth table
- How two switches and a light make your first logic circuit
- Nothing. This is the first volume, and it assumes no electronics and no maths beyond counting.
0.1 What digital logic is
Digital logic is about circuits that use only two values, written 0 and 1. Everything a computer does - sums, photos, messages, games - is built by combining 0s and 1s with a few simple rules.
Think of an ordinary light switch. It is either on or off. There is no "slightly on".
Inside every phone and computer are billions of tiny switches called transistors. Each one is either on or off, just like the light switch. A computer is what you get when you join enough of them together in the right way.
Two values, many names
The two values go by several names, and this course uses all of them. They all mean the same thing.
| Written as | 0 | 1 |
|---|---|---|
| A switch | off | on |
| A voltage | low | high |
| A statement | false | true |
| An answer | no | yes |
A single 0 or 1 is called a bit. On its own, one bit can only say one of two things: on or off, yes or no.
Bits in groups
One bit is not much. Put bits side by side, though, and the number of patterns grows fast. Two bits can make four patterns:
00
01
10
11
Add a third bit and every one of those four patterns can now end in 0 or in 1. That makes eight. Each extra bit doubles the count:
| Bits | Patterns |
|---|---|
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 8 | 256 |
Eight bits make 256 patterns. That is enough to give every letter, digit and punctuation mark on a keyboard its own code, and Volume 01 shows how.
Logic: rules for bits
A rule that decides an output from some inputs is called logic. You already know plenty of them: "the alarm rings if a door is open and the alarm is switched on". The door is open or not, and the alarm is on or not. The answer is yes or no. Every part of that rule is a bit.
A circuit that follows one small rule like this is a logic gate. Gates are the bricks of digital logic, and this course builds everything from them.
A logic gate is like a doorkeeper with one fixed rule. You may come in if you have a ticket and your name is on the list. The doorkeeper does not think or guess. The answer depends only on the two facts in front of them, and the same two facts always get the same answer.
Digital logic is not hard maths. It is a small set of yes-or-no rules, used over and over again. The only difficulty is keeping track, and tables do that for you.
How many different patterns can 4 bits make?
Show the answer
Answer: C. Each extra bit doubles the count: 1 bit makes 2, then 4, 8 and 16. Four bits make 16 patterns, from 0000 to 1111.
0.2 Analogue and digital
An analogue signal can take any value. A digital signal is read as one of just two values, with a wide gap between them. That gap is what makes digital circuits so reliable.
The world is analogue. The temperature in a room does not jump from 20 °C to 21 °C. It passes through every value in between. The voltage from a microphone rises and falls smoothly with the sound.
Reading a voltage as 0 or 1
A digital circuit also works with voltages, but it only cares which side of a line a voltage is on. For example, a chip running from a 5 V supply might read anything above 3.5 V as a 1, and anything below 1.5 V as a 0. Each of those lines is a threshold.
The voltages between the two thresholds are the forbidden zone. A signal passes through it on its way from 0 to 1, but it must not stay there, because the chip might read it either way. In the table below, a question mark means a voltage in the forbidden zone.
| Voltage (V) | Read as |
|---|---|
| 4.70 | 1 |
| 0.20 | 0 |
| 3.90 | 1 |
| 1.10 | 0 |
| 2.50 | ? |
| 3.40 | ? |
| 0.00 | 0 |
| 5.00 | 1 |
The exact thresholds differ from chip to chip, and each chip's datasheet gives them. Volume 09 looks at real chips. Until then, 3.5 V and 1.5 V are all you need.
Noise, and why digital shrugs it off
Every wire picks up noise: small unwanted wobbles from nearby wires, motors and power supplies. Figure 0.1 shows a digital signal carrying the eight bits 1 0 1 1 0 1 0 0. It picked up a lot of noise on the way, which shifted some samples by as much as 1.17 V.
The receiving chip reads each bit in the middle of its time slot:
| Bit | Sent | Voltage in the middle (V) | Read as |
|---|---|---|---|
| 0 | 1 | 4.07 | 1 |
| 1 | 0 | 0.59 | 0 |
| 2 | 1 | 4.85 | 1 |
| 3 | 1 | 4.52 | 1 |
| 4 | 0 | 1.02 | 0 |
| 5 | 1 | 4.35 | 1 |
| 6 | 0 | 0.38 | 0 |
| 7 | 0 | 1.00 | 0 |
Every bit comes back right. Some 1s arrived as low as 3.83 V and some 0s as high as 1.08 V, and it made no difference. The noise changed the voltages, but not what they meant.
Better still, the chip does not pass the noise on. Every gate reads its inputs as clean 0s and 1s, then drives its own output at full strength. This is called regeneration. It means a digital signal can pass through gate after gate without getting any worse.
An analogue signal has no such luck. Say a wire carries 2.40 V, picks up 0.09 V of noise and arrives as 2.31 V. The circuit at the far end has no way to know. As far as it can tell, 2.31 V is the real value, and the error stays for good.
Pass a whispered sentence along a line of people, and by the end the words have changed. That is analogue. Now pass a card along the line with one big word on it: YES or NO. A smudged card is still easy to read, and each person can write a fresh, clean card before passing it on. That is digital, with regeneration.
Why two values and not ten?
Why not use ten voltage levels, one for each digit from 0 to 9? Each wire would carry more. The trouble is noise. Split 0 V to 5 V into equal slices, one slice per level. A value in the middle of its slice can only wobble by half a slice before it lands in the wrong one.
| Levels | Slice width (V) | Room for noise (V) |
|---|---|---|
| 2 | 2.5 | 1.25 |
| 4 | 1.25 | 0.625 |
| 10 | 0.5 | 0.25 |
Two levels leave five times as much room for noise as ten. A circuit that only has to tell two values apart can also be small, fast and cheap. That is why billions of them fit on one chip.
"Digital means there are no in-between voltages." Not so. Underneath, the wire is still analogue: its voltage rises and falls smoothly, and it carries noise like any other wire. Digital is a way of reading it. Each voltage is sorted into 0 or 1 by comparing it with the thresholds.
A chip on a 5 V supply reads anything above 3.5 V as 1 and anything below 1.5 V as 0. A 1 was sent, and it arrives as 3.9 V. What does the chip read?
Show the answer
Answer: B. 3.9 V is above the 3.5 V threshold, so the chip reads 1. The noise changed the voltage but not the meaning, and the chip's own output will be a clean, full-strength 1 again.
0.3 How this course works
Each volume adds one layer: numbers, then gates, then ways to simplify them, then building blocks, then memory. Every lesson uses the same three pictures: truth tables, circuit diagrams and timing diagrams.
The route
| Part | Volumes | What you get |
|---|---|---|
| Numbers and gates | 00 to 02 | Bits, binary and hex numbers, and the seven basic gates |
| Simplifying logic | 03 and 04 | Boolean algebra and Karnaugh maps: the same job with fewer gates |
| Building blocks | 05 and 06 | Multiplexers, decoders, comparators, and circuits that add and subtract |
| Memory and time | 07 and 08 | Latches and flip-flops, then registers, counters and shift registers |
| Real chips and revision | 09 and 10 | Memory chips, converters, logic families, and GATE-style problems |
Volumes 01 to 06 are about combinational logic: circuits whose output depends only on their inputs right now. Volumes 07 and 08 add sequential logic: circuits with memory, whose output also depends on what happened before.
Take the volumes in order. Each one only uses what came before it.
Three pictures of one circuit
- A truth table lists every input pattern and the output for each one. Because it lists every pattern, nothing is left out.
- A circuit diagram shows the gates and the wires between them.
- A timing diagram shows signals changing over time. Time runs from left to right, and a line drawn high means 1.
A truth table needs one row for every input pattern. So a circuit with 3 inputs needs 8 rows, and one with 4 inputs needs 16. The next sub-module draws all three pictures for the same small circuit.
How each lesson is built
- The big idea in one or two sentences, so you know where the lesson is going.
- Plain words first, then an everyday picture, then the exact version.
- Worked examples, with every step shown.
- A common mistake, because knowing the trap is half of knowing the rule.
- A quick check at the end of each sub-module.
Beside these lessons sits a small logic simulator. It works out every truth table, conversion and timing diagram, and a test script compares its answers with what the pages say. It also simulates each circuit drawing, so a drawing can never disagree with its table.
What you need
A pencil and paper. Most of this course is small tables that you fill in by hand. If you want to build the circuits yourself, a free online simulator such as CircuitVerse lets you place gates, flick switches and watch lamps light. It is optional: nothing in the course needs it.
Fill in the tables yourself before you read the answers. Reading a truth table feels easy; writing one is how the rules stick.
A circuit has 3 inputs. How many rows does its truth table need?
Show the answer
Answer: A. A truth table has one row for every input pattern, and 3 bits make 2 × 2 × 2 = 8 patterns. The rows run from 000 to 111.
0.4 A first circuit: one light, two switches
Two switches and a lamp already make a logic circuit. Joined one after the other, the lamp needs both switches on - that is AND. Joined side by side, either switch will do - that is OR.
Take a battery, a lamp and two switches, A and B. A closed switch lets current through: call that 1. An open switch stops it: call that 0. The lamp is 1 when it is lit and 0 when it is dark.
In series: both must be on
In the left circuit the switches are in series. The current has to go through A and then through B, so if either one is open, the path is broken.
| A | B | lamp |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The lamp lights on only one row out of four: when A and B are both 1. That is the rule of an AND gate.
In parallel: either one will do
In the right circuit the switches are in parallel. The current can go through A or through B, so one closed switch is enough.
| A | B | lamp |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
This time the lamp is dark on only one row: when both switches are open. It lights when A or B is 1, which is the rule of an OR gate.
The same two circuits as gates
Drawing batteries and switches every time would be slow. So digital designers draw the rule instead, as a symbol. Figure 0.3 shows both circuits again. The D-shaped symbol is an AND gate, and the one with the curved back is an OR gate.
Each gate takes bits in on the left and gives one bit out on the right. Volume 02 is all about gates like these.
The same two circuits over time
A timing diagram tells the same story as the tables, as it happens. In Figure 0.4, someone flicks A and B at eight moments, and both lamps follow.
Each column of the timing diagram is one row of a truth table. The diagram just shows the rows in the order they happened.
A puzzle: the staircase light
Many houses have a light that can be switched from both the top and the bottom of the stairs. Either switch turns it on or off, whatever the other one is doing. How does that work?
The answer is a pair of two-way switches. Each one joins its middle contact to one of two long wires: to wire 1 when it is up, and to wire 2 when it is down.
The lamp lights when both switches point the same way, because then they pick the same wire and complete the path. Calling up 1 and down 0:
| A | B | lamp |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Now look down the table. From any row, flip either switch and the lamp changes. That is exactly what a staircase needs. This rule - the output is 1 when the two inputs are equal - has a name too, and Volume 02 gives it.
Two switches are in series with a lamp. Switch A is closed and switch B is open. What does the lamp do?
Show the answer
Answer: D. In series the current must pass through both switches. B is open, so the path is broken and the lamp stays off. That is the AND rule: 1 and 0 gives 0.
What you learned
- Digital logic works with two values, 0 and 1, and a single one is called a bit.
- Each extra bit doubles the number of patterns: 2, 4, 8, 16, and 256 for eight bits.
- An analogue signal can take any value. A digital signal is read as 0 or 1 by comparing its voltage with thresholds.
- The voltages between the thresholds are the forbidden zone. A signal may pass through it, but must not stay there.
- Noise cannot change a digital value unless it pushes the voltage past a threshold, and every gate sends out a clean copy.
- Two levels leave five times as much room for noise as ten.
- Switches in series make AND, and switches in parallel make OR.
- A truth table, a circuit diagram and a timing diagram are three views of the same circuit.
Key words from this volume
Every word below has a plain-English entry in the glossary.
- Digital logic
- Transistor
- Bit
- Logic gate
- Analogue signal
- Digital signal
- Voltage
- Threshold
- Forbidden zone
- Noise
- Regeneration
- Combinational logic
- Sequential logic
- Truth table
- In series
- AND gate
- In parallel
- OR gate
- Timing diagram
- Two-way switch
Practice
Codes for a keypad
A keypad sends a different pattern of bits for each of its keys. If it uses 6 bits, how many keys can it tell apart? And how many bits would it need for 100 keys?
Show the solution
Each bit doubles the count, so 6 bits make 2 × 2 × 2 × 2 × 2 × 2 = 64 patterns: enough for 64 keys.
For 100 keys, keep doubling until you pass 100. Six bits make only 64, which is too few. Seven bits make 128, which is enough, so the keypad needs 7 bits. Some of the 128 patterns are simply never used.
Read the voltages
A chip on a 5 V supply reads anything above 3.5 V as 1 and anything below 1.5 V as 0. What does it make of 0.80 V, 4.10 V, 3.60 V, 1.60 V and 2.90 V?
Show the solution
Compare each voltage with the two thresholds:
| Voltage (V) | Read as |
|---|---|
| 0.80 | 0 |
| 4.10 | 1 |
| 3.60 | 1 |
| 1.60 | ? |
| 2.90 | ? |
3.60 V is only just above 3.5 V, but that is enough for a 1. 1.60 V and 2.90 V are both in the forbidden zone, so the chip could read them either way - a design that leaves a signal there is broken.
Three switches in series
Three switches, A, B and C, are joined in series with a lamp. Write the truth table. On how many rows does the lamp light?
Show the solution
Three inputs need 2 × 2 × 2 = 8 rows. The current must pass through all three switches, so the lamp lights only when every one of them is closed:
| A | B | C | lamp |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |
The lamp lights on one row out of eight. This is a three-input AND: all of A and B and C must be 1.
The staircase, one flip at a time
On the staircase, both switches start down and the lamp is lit. Someone flips A, then B, then A, then A again. Is the lamp on or off after each flip?
Show the solution
The lamp is lit whenever the switches point the same way. Follow it flip by flip:
- Start: A down, B down. Same way, so the lamp is on.
- Flip A: A up, B down. Different, so off.
- Flip B: A up, B up. Same, so on.
- Flip A: A down, B up. Different, so off.
- Flip A: A up, B up. Same, so on.
Every single flip changed the lamp, whichever switch it was. That is the whole point of the circuit.
Interview corner
Analogue or digital?
"What is the difference between an analogue signal and a digital one?"
Show the solution
"An analogue signal can take any value in a range, and its exact value carries the information - a microphone voltage, say. A digital signal is read as one of a few fixed values, usually two. The receiver compares the voltage with thresholds and decides 0 or 1.
That makes a digital signal much better at resisting noise. Noise changes the voltage, but unless it pushes it past a threshold, the value read stays the same. And each gate regenerates the signal, so noise does not build up from stage to stage."
Why binary?
"Why do computers use two voltage levels instead of ten?"
Show the solution
"Because two levels are far easier to tell apart reliably. With 0 to 5 V split into equal slices, two levels leave 1.25 V of room for noise, while ten leave only 0.25 V - five times less. A circuit that only has to decide between two values can also be very simple, small and fast, which is what lets billions of them share one chip."
Volume 01 starts using bits for real: how to count, add and write negative numbers with nothing but 0s and 1s.