Teaching unit

Digital electronics

Ages: 15-16 Subject: Technology Sessions: 10-12 Curriculum: Region of Murcia (Spain)
▸ Step 0 · Map of the unit

What is this unit about?

Your phone, the washing machine and the traffic light on the corner do not understand “more or less”: they only tell apart 0 and 1. With just those two digits they store numbers, photos and music, and with tiny parts, the logic gates, they make decisions. Look at the whole map before you start, and come back here whenever you get lost.

🎮 Shown in the lab
Signals
Binary
Gates
Functions
Chips

DIGITAL ELECTRONICS

The electronics that works with two states, 0 and 1: numbers are written in binary and decisions are made by logic gates, which come inside chips.

Analog and digital

Two ways of carrying information · 5 concepts

An analog signal can take any value; a digital one, only two: 0 and 1. Each 0 or 1 is a bit.
Analog signal

Any value: the hand of a clock

Digital signal

Only two values: 0 and 1

The 0 and 1 levels

0 = near 0 V · 1 = near 5 V

Bit and byte

1 bit = a 0 or a 1 · 1 byte = 8 bits

Why digital

It resists noise and copies without losing anything

The binary system

Counting with two digits · 4 concepts

In binary each digit is worth twice the one to its right: 1, 2, 4, 8, 16… To convert to decimal, add up the weights of the ones.
The weights

128 · 64 · 32 · 16 · 8 · 4 · 2 · 1

Binary to decimal

1101 = 8 + 4 + 1 = 13

Decimal to binary

Subtract weights or divide by 2

How many numbers fit

With n bits, 2n combinations

Logic gates

The parts that decide · 7 concepts

A logic gate receives zeros and ones and gives a 0 or a 1 following a fixed rule, written in its truth table.
The truth table

All the possible inputs and their output

NOT

Flips it: 0 → 1 and 1 → 0

AND

1 only if both are 1

OR

1 if either is 1

NAND

A negated AND

NOR

A negated OR

XOR

1 if they differ

Logic functions

Reading and designing circuits · 5 concepts

A gate circuit is written as an expression (S = A·B + C). It can be read (from circuit to table) or designed (from problem to circuit).
The expression of a circuit

· is AND, + is OR, the bar is NOT

Boolean algebra

The rules for simplifying

From problem to table

Inputs, outputs and when it turns on

Sum of products

One product for each row with a 1

Karnaugh map

Grouping ones to simplify

Integrated circuits

The real gates · 4 concepts

Gates are bought inside chips with 14 pins, like the 74HC08 (four ANDs). They run on 5 V and are mounted on a breadboard.
The 74HC family

One chip for each type of gate

Power supply

Pin 14 to +5 V and pin 7 to ground

Inputs and outputs

Switch with resistor · LED with resistor

How many chips

4 gates per chip (6 if they are NOT)

Where do I start? With lesson 1. The branches go in order: first what a digital signal is, then how numbers are written with zeros and ones, then the gates that decide with them and, at the end, how circuits are read, designed and built.

▸ The course cheat sheet

The seven gates

The American symbol (top) and the European one (below), the expression and the truth table of each gate, drawn by the lab. Keep this sheet at hand throughout the unit.

Top: American symbol (ANSI). Below: European (IEC). A and B are inputs; S is the output.NOT(inverter)1S = AAS0110AND(product)&S = A · BABS000010100111OR(sum)≥1S = A + BABS000011101111NAND(not-AND)&S = A · BABS001011101110NOR(not-OR)≥1S = A + BABS001010100110XOR(exclusive OR)=1S = A BABS000011101110XNOR(equivalence)=1S = A BABS001010100111
Lesson 1

Analog and digital

🌡️

The glass thermometer your grandparents had has a red line that rises gradually: it can stop at 36.7 or at 36.73. The one aimed at your forehead shows a number and beeps. Both measure the same thing, but they give it in a different way: the first is analog and the second, digital. Inside, that number is zeros and ones.

Definition

A signal is a quantity that carries information, like a voltage that goes up and down. It is analog if it can take any value and changes continuously; it is digital if it only takes certain values. In digital electronics, only two: 0 and 1.

1.1 · Two ways of giving a piece of data

The temperature of a room does not jump straight from 20 to 21 °C: it goes through 20.1, 20.25 and every value in between. It is an analog quantity. A push button, on the other hand, is only pressed or released: there is no in-between. It is digital.

Analog temperature through the day: any value time temperature Digital a push button: only high (1) or low (0) 5 V 3.5 V 1.5 V 0 V 0 1 0 1 0 reads as 1 reads as 0

On the left, the curve can go through any value. On the right, the signal is only high or low, and each section reads as a 1 or a 0.

⌚ The clock

The hands turn without jumping: analog. The numbers on a display change minute by minute: digital.

🎵 Music

The groove of a vinyl record copies the sound wave: analog. An MP3 or streaming are millions of zeros and ones.

💡 Light

A dimmer that raises it little by little is analog. A switch, on or off, is digital.

🌡️ The thermometer

The mercury line that rises is analog. The number that beeps, digital: inside, it stores the measurement in binary.

1.2 · 0 and 1 are voltages

Inside a digital circuit, 0 and 1 are not written numbers: they are voltages. In the chips you will use, powered at 5 V:

  • a voltage between 0 and 1.5 V is read as a 0 (low level, L);
  • one between 3.5 and 5 V is read as a 1 (high level, H);
  • anything in between is a forbidden zone: a well-built circuit never stays there.

Notice what that means: if a 1 reaches 4.6 V instead of 5 V because the wire is long or there is noise (small disturbances from other devices), the chip still reads it as a 1. The information arrives intact.

Key idea

That is why almost everything is digital today: a little noise does not turn a 0 into a 1, and a copy of a copy is exactly the same as the original. A cassette tape, on the other hand, loses quality every time it is copied.

1.3 · The bit and the byte

Each 0 or 1 is a bit (from binary digit). A bit only says one thing out of two: yes or no, on or off. To store more, bits are put together: 8 bits make a byte, enough for one letter.

UnitEqualsEnough for…
1 bita 0 or a 1knowing whether a push button is pressed
1 byte (B)8 bitsone letter of a message
1 kilobyte (kB)1,000 byteshalf a page of text
1 megabyte (MB)1,000 kBone minute of an MP3 song
1 gigabyte (GB)1,000 MBa short movie on your phone

1.4 · From analog to digital

The world is analog: light, sound and temperature change gradually. That is why sensors give an analog voltage, and a converter (ADC) turns it into digital: it measures it many times per second and writes each measurement with bits. A phone microphone is sampled about 48,000 times per second; the more measurements, and the more bits per measurement, the more the digital copy resembles the original.

✔ Worked example · analog or digital?
The challenge: classify three parts of a house: the doorbell push button, an LDR (the resistor that changes with light) and the heating thermostat.
1️⃣ The doorbell push button. It has only two states: pressed or released. It gives a digital signal: 1 when you press it, 0 when you do not.
2️⃣ The LDR. Its resistance falls gradually as there is more light, without jumps: it gives an analog signal, which can take any value.
3️⃣ The thermostat. It measures temperature, which is analog, but what it does is decide: it switches the heating on (1) or off (0). Its output is digital.
Result: push button, digital; LDR, analog; thermostat, analog in and digital out. This is the most common case: you measure in analog and decide in digital. The decisions are made by the logic gates of lesson 3.
▸ Check what you have understood

Practice: 6 exercises

They cover the three ideas of the lesson: what makes an analog signal different from a digital one, how 0 and 1 are read and what the bit and the byte are.

Concepts

1. Which of these signals is digital?

Find it

2. Only one of these three signals is digital. Tap it.

A B C
Match

3. Match each word with its meaning. Tap one on the left and then its partner on the right.

Apply

4. In a 5 V circuit, a long wire next to a motor picks up noise, and a 1 reaches the chip at 4.2 V. What does the chip read?

Fill in the blanks

5. Fill in the blanks:

A byte has bits. With a single bit you can give different answers. Sensors usually give a signal that is , and the converter measures it many times per second to store it in .
Put in order

6. You record a voice note and send it to a friend. Put the journey of your voice in order:

The converter measures that voltage thousands of times per second
You speak: your voice is a wave in the air
It travels over the internet as zeros and ones and arrives intact
The microphone turns it into an analog voltage
Each measurement is stored as a group of bits
Lesson 2

The binary system

🔢

You count with ten digits, from 0 to 9, probably because you have ten fingers. A computer has only two: 0 and 1. And even so it stores your age, the price of your sneakers and the 16 million colors of a photo. The trick is the binary system, and in this lesson you will learn to read and write it.

Definition

The binary system is a way of writing numbers with only two digits, 0 and 1. It is a base 2 system: each position is worth twice the one to its right.

2.1 · What you already know: base 10

In the number 345, the 3 is not worth 3: it is worth 300, because it is in the hundreds position. Each position is worth ten times the one to its right: ones, tens, hundreds…

345 = 3 · 100 + 4 · 10 + 5 · 1

Binary works the same way, but each position is worth twice the one to its right. Those values are called weights:

12827
6426
3225
1624
823
422
221
120

To avoid mixing up a binary number with a decimal one, the base is sometimes written below: 1012 is five, and 10110, one hundred and one.

2.2 · From binary to decimal: add the weights of the ones

Write the number under the weights, starting from the right, and add the weights that have a 1 under them. Zeros add nothing. This is how 101101 is read:

132
016
18
14
02
11

1011012 = 32 + 8 + 4 + 1 = 45

2.3 · From decimal to binary: two methods

Subtracting weights. Find the biggest weight that fits in your number, put a 1 under it and subtract it. Carry on with what is left, weight by weight to the right: if it fits, write 1 and subtract; if it does not fit, write 0.

Dividing by 2. Divide the number by 2, write down the remainder (0 or 1) and divide the quotient again, until the quotient is 0. The binary number is the remainders read from bottom to top. With 37:

DivisionQuotientRemainder
37 : 2181
18 : 290
9 : 241
4 : 220
2 : 210
1 : 201 ↑

From bottom to top: 37 = 1001012. Check it by adding weights: 32 + 4 + 1 = 37.

2.4 · How many numbers fit?

With 1 bit there are 2 possibilities (0 and 1); with 2 bits, 4 (00, 01, 10, 11); with 3 bits, 8. Each extra bit doubles the combinations:

Formula

With n bits there are 2n combinations, from 0 to 2n − 1. With 4 bits, 16 numbers (0 to 15); with 8 bits, a byte, 256 (0 to 255).

This is how you count from 0 to 7 with 3 bits. Look at the right-hand column, which changes every time, and the left-hand one, which changes half as often. You will use this order in all the truth tables of lesson 3:

Decimal421
0000
1001
2010
3011
4100
5101
6110
7111

A trick: a binary number ending in 0 is even, and one ending in 1 is odd, because the only odd weight is the one on the right.

✔ Worked example · there and back
The challenge: convert 1100102 to decimal, and 23 to binary.
1️⃣ 110010 to decimal. It has 6 digits: its weights, from left to right, are 32, 16, 8, 4, 2 and 1. There are ones under the 32, the 16 and the 2.
2️⃣ I add those weights: 32 + 16 + 2 = 50. It ends in 0: it is even, so it checks out.
3️⃣ 23 to binary, subtracting weights. 32 does not fit. 16 does: 1, and 7 is left. 8 does not fit in 7: 0. 4 does: 1, 3 left. 2 does: 1, 1 left. 1 does: 1, 0 left.
4️⃣ I read the digits in order (16, 8, 4, 2, 1): 1, 0, 1, 1, 1. I check: 16 + 4 + 2 + 1 = 23.
Result: 1100102 = 50 and 23 = 101112. Always checking with the sum of weights avoids most mistakes.
Practice on your own

Practice on paper: write the weights 128, 64, 32, 16, 8, 4, 2, 1 above a row of eight boxes. Convert your age, the day of your birthday and your house number to binary, then convert them back and check that you get the same number. Then try the letter A: its code is 65, so as a byte it is 01000001.

▸ Check what you have understood

Practice: 6 exercises

Converting from binary to decimal, from decimal to binary and knowing how many numbers fit in a given number of bits. Keep paper at hand: write the weights down before calculating.

Calculate

1. What decimal number is 10112?

2. And 11001002? (It has 7 digits: the weight of the first one is 64.)

3. How is 26 written in binary?

Fill in the blanks

4. Fill in the blanks:

With 4 bits you can write different numbers, from 0 to . The highest number that fits in a byte is . The binary number 1110 is .
Put in order

5. Put these binary numbers in order from smallest to largest:

1010
0111
1100
0011
1001
Match

6. Match each binary number with its decimal number.

Lesson 3

Logic gates

🛗

You press the elevator button and it does not move: someone has left the door open. The elevator has made a decision: it moves if you press the button AND the door is closed. That “AND” is done by a tiny circuit, a logic gate. Your phone has billions of them, and in this lesson you will meet the seven that exist.

Definition

A logic gate is a circuit that receives one or more digital inputs (0 or 1) and gives an output, also 0 or 1, following a fixed rule. That rule is written in its truth table.

3.1 · The truth table

Inputs are named with letters (A, B, C…) and the output, S. The truth table lists all the possible combinations of the inputs and the output for each one. With two inputs there are 22 = 4 rows; with three, 23 = 8. They are written in binary counting order (00, 01, 10, 11), so none is forgotten.

3.2 · The three basic ones: NOT, AND and OR

All three can be understood with switches and a bulb, as in the circuits you already know: a closed switch is a 1, and a lit bulb is another 1.

AND: switches in series lights only if A and B are closed + A B S S = A · B OR: switches in parallel lights if A, B or both are closed + A B S S = A + B

In series, the current has to go through both: you need A and B. In parallel, one of the two paths is enough: A or B.

NOT

Inverter

1

S = A (read “not A”)

AS = A
01
10

Flips the input: if 1 comes in, 0 comes out. It is a push button that switches off when pressed, like the fridge light.

AND

Logical product

&

S = A·B («A y B»)

ABS = A·B
000
010
100
111

Gives 1 only if all the inputs are 1. Like multiplying: a single 0 is enough to make the output 0. It is switches in series.

OR

Logical sum

≥1

S = A + B («A o B»)

ABS = A + B
000
011
101
111

Gives 1 if any input is 1 (or both). Careful: in logic, 1 + 1 = 1. It is switches in parallel.

3.3 · The negated ones and the XOR

The other gates come from combining these. A small circle on the output of the symbol means negation: the NAND is an AND with its output flipped, and the NOR, an OR.

NAND

Negated AND

&

S = A·B

ABS = A·B
001
011
101
110

The opposite of the AND: gives 0 only if both are 1. Any other gate can be built with NANDs.

NOR

Negated OR

≥1

S = A + B

ABS = A + B
001
010
100
110

The opposite of the OR: gives 1 only if both are 0. “Neither A nor B”.

XOR

Exclusive OR

=1

S = A ⊕ B

ABS = A ⊕ B
000
011
101
110

Gives 1 when the inputs are different. It is the staircase light: it can be switched from downstairs or from upstairs.

There is a seventh one, the XNOR (negated XOR), which gives 1 when the inputs are equal. It is rarely used: it is in the cheat sheet on the Map tab.

3.4 · Two ways of drawing them

Each gate has two symbols. The American one (ANSI standard) tells the gates apart by their shape: the AND is a “D”, the OR an arrowhead and the NOT a triangle. The European one (IEC standard) is always a rectangle with a sign inside: & for the AND, ≥1 for the OR, =1 for the XOR and 1 for the NOT. In both, the small circle is negation. Here we mostly use the American one, which is the one you will see most often.

To remember

AND: all at 1 · OR: any at 1 · NOT: the opposite · the small circle negates · XOR: different. And if in doubt, write the table: with two inputs it is only four rows.

✔ Worked example · which gate do I need?
The challenge: the car beeps if you leave the lights on (A = 1) and open the door (B = 1). Which gate is needed?
1️⃣ I write the table. Two inputs, four rows: 00, 01, 10 and 11.
2️⃣ I fill in the output row by row. With the lights off (A = 0) it never beeps: 0 and 0. With the lights on and the door closed (10), it does not beep either: 0. Only with both at 1 (11) does it beep: 1.
3️⃣ I look for the gate that has that table: 0, 0, 0, 1. It is the table of the AND.
Result: an AND, S = A · B. The clue was in the sentence: “lights on and door open”. When the problem says “and”, it is usually an AND; when it says “or”, an OR; and “not”, a NOT.

3.5 · In the lab

The logic gate lab has six modes. In this lesson two of them are useful. The gates shows the seven cards, with their two symbols and their table. And in Practice, level 1 (“one gate”) asks you what the LED shows or which gate it is, in rounds of ten. Start with the cards:

Logic gate lab · The gates Tap to load the interactive lab

↗ Open full screen

▸ Check what you have understood

Practice: 6 exercises

Recognizing each gate by its symbol and by its table, and knowing which one to use in a problem.

Match

1. Match each symbol with its name.

Apply

2. A workshop press only comes down if the operator presses both buttons at the same time, one with each hand, so that a hand cannot be underneath. Which gate does it need?

3. Which gate has this truth table?

ABS
001
010
100
110
Fill in the blanks

4. Fill in the blanks:

A NOT gate has this many inputs: . The output of a NAND is always the opposite of the output of this gate: . An XOR gives 1 when its two inputs are . In the symbol, the small circle on the output means .
Calculate

5. An AND gate with three inputs (A, B and C): how many rows does its truth table have?

rows
Find it

6. With A = 1 and B = 0, one of these gates gives 1; and with A = 1 and B = 1, it gives 0. Tap it.

1234
Lesson 4

From circuit to table

🔍

A technician gives you the diagram of a house alarm: three switches, two gates and an LED. Before building it you want to know when it will sound. There is no need to test it with the house full of burglars: the diagram can be read, like a sentence, and turned into a table that says it all.

Definition

Analyzing a logic circuit means finding out what it does: writing its logic function (the expression of the output, like S = (A + B) · C) and, with it, its truth table.

4.1 · How an expression is written

Each gate has its own sign, like the operations in math:

GateWrittenRead
ANDA·BA and B (a dot, like multiplying)
ORA + BA or B (a plus, like adding)
NOTAnot A (a bar on top)
NANDA·Bthe bar covers the whole AND
XORA ⊕ BA exclusive-or B

The order is the one from math: first what is under a bar, then the products (AND) and finally the sums (OR). If you want an OR to be done first, use parentheses: A·B + C is not the same as A·(B + C).

4.2 · Reading the circuit from left to right

Start with the gates that only touch switches and write the output of each gate above its wire. Each output is the input of the next one. When you reach the LED, you have the whole expression. This is the house alarm: A is the door, B the window and C the key that arms it.

A1B0C11 · OR2 · ANDS

With the door open (A = 1), the window closed (B = 0) and the alarm armed (C = 1), the LED lights up.

4.3 · The table, with helper columns

With three inputs, the table has 8 rows. Between the inputs and the output put one column for each gate: that way each value comes from the previous column, with no mental math.

ABCA + BS = (A + B)·C
00000
00100
01010
01111
10010
10111
11010
11111

4.4 · A little Boolean algebra

Logic expressions have their own rules, called Boolean algebra. They are used to simplify an expression before building it, and a shorter circuit needs fewer gates. These are the most common ones (replace A with a 0 and then with a 1 and you will see that they hold):

With ANDWith ORWhat it says
A·0 = 0A + 1 = 1a 0 cancels the AND; a 1 fills the OR
A·1 = AA + 0 = Athe 1 in an AND and the 0 in an OR change nothing
A·A = AA + A = Arepeating adds nothing (here 1 + 1 = 1)
A·A = 0A + A = 1something and its opposite
A·B = A + BA + B = A·BDe Morgan's laws: when the bar is broken, the sign changes

And the double negation: A = A. You can prove any of these rules by comparing truth tables in Free mode in the lab.

Key idea

Circuit, expression and table are three ways of saying the same thing. From the circuit you get the expression, reading it from left to right; from the expression you get the table, row by row. In lesson 5 you will make the trip the other way.

✔ Worked example · when does the alarm sound?
The challenge: analyze the alarm in the drawing and say in which cases it sounds.
1️⃣ The inputs and the output. A, the door (1 = open); B, the window (1 = open); C, the key (1 = alarm armed). S, the siren.
2️⃣ Gate 1 is an OR with A and B: its output is A + B (“the door or the window is open”).
3️⃣ Gate 2 is an AND with that output and with C. Since the OR has to be done first, it goes in parentheses: S = (A + B)·C.
4️⃣ The table. First the column A + B (it is 1 in every row except the two that start with 00); then S, which is 1 where A + B and C are both 1.
Result: S = (A + B)·C, and the siren sounds in 3 of the 8 rows: 011, 101 and 111. With the key removed (C = 0) it never sounds, even if you open everything.

4.5 · In the lab

The Build mode starts with this same alarm (there the key goes to the top input of the AND). Press the switches A, B and C and watch the LED. On the right, the lab writes the function and the truth table, and marks the row you are on: press a row and it sets the switches. Then, in Practice, level 2, you have circuits with two and three gates to read.

Logic gate lab · Build Tap to load the interactive lab

↗ Open full screen

▸ Check what you have understood

Practice: 6 exercises

Going from the circuit to the expression, from the expression to the table, and using the first rules of Boolean algebra.

Read the circuit

1. The seat belt beep: A is the engine on and B, the seat belt fastened. What expression does this circuit have?

AB1 · NOT2 · ANDS

2. This other circuit gives S = A·B + C. Make its truth table (8 rows): in how many rows is the output 1?

ABC1 · AND2 · NOT3 · ORS
rows
Put in order

3. Put the steps for analyzing a circuit in order:

Put it all together in the expression for S, with parentheses where needed
Check one row with the switches in the lab
Name the inputs and the output
Make the table, with a helper column for each gate
Write the output of each gate, from left to right
Boolean algebra

4. Complete the rules:

A·0 = ; A + 1 = ; A·A = ; A + A = .

5. By De Morgan's laws, what is A·B equal to?

Match

6. Match each expression with what it says in words. Pay attention to the parentheses.

Lesson 5

From problem to circuit

🗳️

In a talent show, three judges vote with a push button. The green light comes on when two or more vote yes. Nobody gives you the diagram: you are only given that sentence. In this lesson you will go the opposite way to lesson 4: from the sentence to the circuit, with a method that always works.

Definition

Designing a logic circuit means starting from what it has to do, told in words, and arriving at the gates that do it: problem → truth table → function → simplification → circuit.

5.1 · The six steps

  1. Inputs and outputs. Give a letter to each sensor or push button and say what its 1 means (A = 1: “judge A votes yes”). Do the same with the output.
  2. The truth table. All the combinations, in binary counting order, and in each row the output the problem asks for.
  3. The function. It is written as the sum of products (below).
  4. Simplify, with Boolean algebra or with the Karnaugh map: fewer letters, fewer gates.
  5. The circuit. Each product is an AND; the sum, an OR; each bar, a NOT.
  6. Check it in the lab, row by row, against the table.

5.2 · The sum of products

Look only at the rows where the output is 1. Each one gives a product (an AND) with all the letters: the letter goes as it is if it is 1 in that row, and negated if it is 0. Then all the products are added (OR). For example, if the output is 1 in the row A=0, B=1, C=1, its product is A·B·C: that AND only gives 1 in that row.

The sum of products always works, but it tends to come out long. That is why it is simplified before building it.

5.3 · The Karnaugh map

It is the same truth table, placed in a grid in which two neighboring cells differ in only one letter. That is why the AB columns go in the order 00, 01, 11, 10 (not 00, 01, 10, 11): from one to the next only one bit changes, and the last one is also a neighbor of the first. The small number in each cell is its row in the table.

To simplify, group the ones:

  • in rectangles of 1, 2, 4 or 8 cells (powers of 2), never 3 or 6;
  • as large as you can, and as few as you can; a 1 can be in several groups;
  • each group gives a product with the letters that do not change inside the group; the ones that change disappear.
✔ Worked example · the three-judge voter
The challenge: the green light comes on when two or more of the three judges vote yes.
1️⃣ Inputs and output. A, B and C, the three judges (1 = votes yes). S, the green light (1 = on).
2️⃣ The table. Eight rows. S is 1 where there are two or three ones: in rows 3 (011), 5 (101), 6 (110) and 7 (111).
ABCS = A·B + A·C + B·C
0000
0010
0100
0111
1000
1011
1101
1111
3️⃣ The sum of products. One AND for each row with a 1: S = A·B·C + A·B·C + A·B·C + A·B·C. It works, but that is four three-input ANDs.
4️⃣ Karnaugh. I put the four ones on the map and make three pairs, all of them including the 1 of cell 7:
ABC00011110010001011101234567
Purple pair (cells 6 and 7): A and B are 1 in both, C changes → A·B. Green pair (3 and 7): B and C fixed, A changes → B·C. Orange pair (5 and 7): A and C fixed → A·C.
5️⃣ The circuit. Three two-input ANDs, one for each pair, and two ORs that join their outputs:
ABC1 · AND2 · AND3 · AND4 · OR5 · ORS
Result: S = A·B + A·C + B·C. It reads just like the problem: “it comes on if A and B vote yes, or A and C, or B and C”. Checked in the lab, it lights up in rows 3, 5, 6 and 7.
Key idea

The table is the step you cannot skip: with it, the problem stops being a sentence and becomes zeros and ones. The rest is method. And at the end, check: a circuit that does not match the table is wrong, even if the calculations look right.

5.4 · In the lab

The From problem to circuit mode takes you through the six steps with eight problems (the alarm, the seat belt, the garage light, the voter, the tank, the irrigation, the garage door and the four judges), and checks each step before letting you move on to the next one. It opens with the voter:

Logic gate lab · From problem to circuit Tap to load the interactive lab

↗ Open full screen

And the Karnaugh mode lets you make the groups yourself, by tapping the cells, and tells you if there are too many or too few. It opens with the ones of the voter:

Logic gate lab · Karnaugh Tap to load the interactive lab

↗ Open full screen

▸ Check what you have understood

Practice: 6 exercises

The design method, the sum of products and the Karnaugh groups.

Put in order

1. Put the steps for designing a circuit from a problem in order:

Simplify with the Karnaugh map
Fill in the truth table with what the problem asks for
Check it row by row in the lab
Give a letter to each input and to the output
Draw the gates: one AND for each product and one OR to add them
Write the sum of products of the rows with a 1
From problem to function

2. A tank has two level sensors: A, at the bottom, and B, at the top (1 = the water covers it). The pump switches on when the water covers neither of them. What function does the pump have?

3. Which sum of products comes from this table?

ABS
000
011
101
110
Karnaugh

4. Complete the rules of the Karnaugh map:

The AB columns go in the order 00, 01, , 10. Groups can have 1, 2, 4 or cells, and it is best for them to be as as possible. In each group, the letters that .

5. These four ones form a single group of four. What simplified function does it give?

ABC00011110010011001101234567
Match

6. When you read a problem, each word tells you a gate. Match them.

Lesson 6

Real chips

🔌

The gates in the lab are drawings. The real ones are made of silicon, smaller than a hair, and come inside little black boxes with legs: chips. With two of them, four wires, a battery and an LED you can build in class the alarm you analyzed in lesson 4. In this lesson you learn to read a chip and connect it.

Definition

An integrated circuit (or chip) is a slice of silicon with many components inside, placed in a plastic package with pins to connect it. The ones in the 74HC family hold several identical logic gates.

6.1 · The 74HC family

Each type of gate has its own chip. All of them have 14 pins (DIP-14 package) and almost all hold four two-input gates; the NOT one holds six, because each one uses only two pins.

ChipHoldsNote
74HC004 NAND gatesany other gate can be made with NANDs
74HC024 NOR gatesit has a different pinout: the output comes before the inputs
74HC046 NOT gatessix, not four
74HC084 AND gates
74HC324 OR gates
74HC864 XOR gates

6.2 · How to read a chip

On top, the chip has a notch at one end (or a dot next to pin 1). Put it on the left: pin 1 ends up at the bottom left and the count goes counterclockwise, up to 14, at the top left. What each pin does is told by its datasheet; this is the pinout of the 74HC08:

74HC08: four AND gates in a 14-pin chip, seen from above11A21B31Y42A52B62Y7GND83Y93A103B114Y124A134B14VCC74HC08VCC, +5 V · GND, ground · A and B, the inputs of each gate · Y, its output. The notch goes on the left and pin 1 at the bottom.

The most important thing: the chip needs power. Pin 14 (VCC) goes to +5 V and pin 7 (GND) to ground (the negative). It is not drawn in gate diagrams, but without it the chip does nothing. 74HC chips work between 2 and 6 V: three AA batteries (4.5 V) or a 5 V USB charger will do.

6.3 · Inputs and outputs

+5 V A 10 kΩ one gate of the 74HC VCC (14) to +5 V · GND (7) to ground input output 330 Ω LED Input: switch and resistor to ground Output: resistor and LED
  • Each input goes to a switch that connects it to +5 V, and also to a 10 kΩ resistor to ground. With the switch closed a 1 comes in; open, the resistor pulls it down to 0. Without it, the input is left “floating” and the chip reads whatever it likes: the LED flickers when you bring your hand close.
  • The output lights an LED with a 330 Ω resistor in series, which limits the current so as not to burn the LED or the chip.
  • Unused inputs go to ground: a floating input, even on a gate you do not use, can make the chip get hot or fail.

Everything is built on a breadboard, with the chip straddling the central channel, so that each pin ends up in its own column.

6.4 · How many chips do I need?

Count the gates of each type. Each type needs at least one chip, and each chip has 4 gates (6 if they are NOT). The voter of lesson 5 has 3 ANDs and 2 ORs: one 74HC08 is enough (it uses 3 of its 4 ANDs) and one 74HC32 (it uses 2 of its 4 ORs). Two chips.

Going further

The NAND is a universal gate: by combining NANDs you can make any other. A NAND with its two inputs joined is a NOT; behind another NAND, it undoes the negation and you get an AND. That is why some factories make whole circuits with a single type of gate.

✔ Worked example · building the alarm with chips
The challenge: turn the alarm of lesson 4, S = (A + B)·C, into chips.
1️⃣ I count the gates. One OR and one AND: a 74HC32 and a 74HC08. Three gates are left over on each.
2️⃣ I power both. On each chip, pin 14 to +5 V and pin 7 to ground.
3️⃣ The OR. Switches A and B, each with its 10 kΩ resistor to ground, to pins 1 and 2 of the 74HC32 (inputs 1A and 1B). Its output, 1Y, comes out of pin 3.
4️⃣ The AND. A wire from pin 3 of the 74HC32 to pin 1 of the 74HC08, and switch C, with its resistor, to pin 2. The output comes out of pin 3 of the 74HC08.
5️⃣ The LED, from pin 3 of the 74HC08 to ground, with its 330 Ω resistor. And the inputs of the six leftover gates, to ground.
Result: two chips, three switches, four resistors and one LED. Test it row by row with the table of lesson 4: it has to light up in 011, 101 and 111.

6.5 · In the lab

The Real chip mode takes the circuit you have in Build (when opened, the alarm) and splits it into 74HC chips: it draws each chip seen from above, with the pins you use labeled, and writes the list of connections in order, with the power supply, the resistors and the leftover inputs. It is the list you need to build it on the breadboard.

Logic gate lab · Real chip Tap to load the interactive lab

↗ Open full screen

Gates are also the basis of what comes next: a board like Arduino or the micro:bit does the same thing, deciding with zeros and ones, but with a program instead of wires. You will see it in programming and robotics.

▸ Check what you have understood

Practice: 6 exercises

Reading a pinout, counting chips and connecting the inputs and outputs properly.

Find it

1. You are going to power the 74HC08. Which pin goes to the + of the 5 V? Tap it.

74HC08: four AND gates in a 14-pin chip, seen from above11A21B31Y42A52B62Y7GND83Y93A103B114Y124A134B14VCC74HC08VCC, +5 V · GND, ground · A and B, the inputs of each gate · Y, its output. The notch goes on the left and pin 1 at the bottom.
Count

2. A circuit has 3 AND gates and 2 ORs. How many 74HC chips do you need, at least?

3. Another circuit needs 7 NOT gates. How many 74HC04 chips are needed?

chips
What is wrong?

4. You build the alarm and the LED switches on and off by itself, without touching the switches, when you bring your hand close. What have you forgotten?

Match

5. Match each chip with what it holds.

Fill in the blanks

6. Fill in the blanks:

The chip is powered through pin to +5 V and pin to ground. With the notch on the left, pin 1 is at the on the left. Unused inputs are connected to .
Review

Test yourself on the whole unit

Twenty-two questions that mix the six lessons, in five parts. Almost nothing looks like what you have already done: devices that have not appeared, new circuits and real faults. Two questions are for writing: compare your answer with the model one. If something goes wrong, the comment tells you where to go back to.

Part A · Signals and binary

1. A camera stores the amount of red of each point of the photo with 8 bits. How many different shades of red can it store?

2. In a robot race, the bib number of each robot is written in binary. What number does robot 10011 have?

3. Which of these parts receives an analog signal?

4. You want to give a binary number to each of the 30 students in a class. How many bits do you need, at least?

bits

5. A photo forwarded a thousand times by a messaging app looks the same as the first one; a song recorded on a cassette tape, copied from tape to tape, sounds worse each time. Explain why.

The photo is digital: it is stored as zeros and ones, and when it is copied exactly the same bits are copied. Even if there is a little noise, a 1 is still read as a 1. The tape is analog: it stores a signal that can take any value, and each copy adds some noise that can no longer be separated from the music. The small losses build up copy after copy.
Part B · The gates

6. A commuter train can only start if its three doors are closed. Each sensor gives 1 with its door closed. Which logic gate lets the train start?

7. This symbol appears in the diagram of a German machine. Which gate is it?

=1

8. The “door open” indicator of a car is switched on by a NAND: it goes out only when both front doors are closed (A = 1 and B = 1). Of the four possible combinations, in how many does the indicator light up?

combinations

9. An OR gate receives A = 1 and B = 1. What comes out?

10. What do the American symbols of the NAND and the NOR have in common?

Part C · Reading circuits

11. What expression does this circuit have?

ABC1 · NOR2 · ANDS

12. With that same circuit, in how many of the 8 combinations does the LED light up?

combinations

13. This circuit adds two bits: S is the digit of the result and T, the one that is “carried”. With A = 1 and B = 1, what do S and T show?

AB1 · XOR2 · ANDST

14. Using Boolean algebra, simplify S = A·B + A·B.

Part D · Designing

15. A reading lamp switches on by itself if it is night (N) and someone is in bed (C); and also, at any time, if its button (P) is pressed. What function does it have?

16. What product does this pair on the Karnaugh map give?

ABC00011110010000110001234567

17. A freight elevator goes up (S = 1) when its button (P) is pressed, the door is closed (C = 1) and the elevator is not overloaded (W = 1 if it is). Write its truth table, its function and which gates it needs.

Three inputs, eight rows. The output is only 1 in one of them: P = 1, C = 1 and W = 0 (row 110). Its product is S = P · C · W̅, and it cannot be simplified further. It needs a NOT for W and a three-input AND (or two two-input ANDs, one after the other).

18. The irrigation of a park uses 4 sensors (humidity, rain, light and wind). How many rows does the truth table of its circuit have?

rows
Part E · Chips and everything together

19. In your component box only one 74HC04 is left. How many different signals can you negate with it?

signals

20. You build a circuit with chips and it does nothing: the LED does not light up with any combination. The switches and the wires between gates are fine. What do you check first?

21. The sign of a small parking lot says how many spaces are free (from 0 to 7) with three LEDs in binary, with weights 4, 2 and 1. There are 5 spaces left. How are the LEDs, from left to right?

22. To light the 4 LED of that sign you need to know whether 4 or more spaces are left. A classmate suggests using one sensor per space and a seven-input OR gate. What do you tell your classmate?

Final project

The greenhouse of the school garden

🌱

In the Region of Murcia (Spain) water is worth gold, and watering at midday is throwing it away: in the sun, a good part evaporates before reaching the roots. A well-designed greenhouse decides by itself when to water and when to open the roof window. You are going to design its brain with logic gates, test it in the lab and build it with real chips.

The brief

Design the circuit that controls the irrigation and the window of a greenhouse from four sensors, test it in the logic gate lab and build it with 74HC chips on a breadboard.

It is not a new topic: it is putting together what you already know. The tables come from lesson 3, the design method from lesson 5 and the assembly from lesson 6. What is new is that this time the circuit has two outputs and you will see it light up on your desk.

The inputs and the outputs

LetterSensorIt is 1 when…In the lab
Hsoil humiditythe soil is dryswitch A
Rrainit is rainingswitch B
Dlight (an LDR)it is daytimeswitch C
Ttemperatureit is hot (above 28 °C)switch D
Woutput: wateringthe drip solenoid valve opensLED S
Voutput: the windowthe motor opens the roof windowLED T

And these are the two rules given by the person who looks after the garden:

  • The irrigation opens when the soil is dry, it is not raining and it is night (at night much less water evaporates).
  • The window opens when it is hot, unless it is raining.
Before you start

Always at 5 V or with batteries. 74HC chips work between 2 and 6 V: never connect them to a wall outlet. Build with the power disconnected, and check pins 14 and 7 twice before switching on: a chip powered the wrong way round gets hot and is ruined.

What you need

Breadboard and wires

A 400-point breadboard and colored wires: red for +5 V, black for ground.

One 74HC04 and one 74HC08

The NOTs and the ANDs. If your design has any OR, a 74HC32 as well.

Four switches

They act as sensors. A four-position DIP switch works very well. Each one with its 10 kΩ resistor to ground.

Two LEDs and two 330 Ω resistors

Blue for the irrigation and red for the window.

5 V power supply

A three-AA battery holder (4.5 V) or a 5 V USB cable.

The logic gate lab

To check the design before building and to get the connection list.

The 5 phases

1

Analyze

⏱ 1 session

Write the truth table of each output. The irrigation depends on H, R and D (8 rows); the window, on T and R (4 rows). Read the rules word by word: “and”, “not”, “unless”.

Deliverable: the two tables.

2

Design

⏱ 1 session

Work out the function of each output (sum of products and, if possible, Karnaugh) and draw the circuit. Look for which gate the two outputs can share.

Deliverable: the two functions and the diagram.

3

Simulate

⏱ 1 session

In Build mode, place 4 switches and the LEDs “S and T”, and build your circuit. Go through the 16 rows of the table the lab writes for you and compare it with yours.

Deliverable: a screenshot of the circuit and the checked tables.

4

Build

⏱ 2 sessions

Go to Real chip mode: it gives you the chips and the connection list in order. Build it on the breadboard, test it row by row and, if something fails, look for the fault starting with the power supply.

Deliverable: a short video of the circuit working.

5

Present

⏱ 1 session

A short report: the tables, the functions, the diagram, what failed and how you fixed it. And explain in class why watering at night saves water.

Deliverable: the report (1-2 pages) and the presentation.

Phases 3 and 4 · in the lab

Open Build, press Clear, choose 4 switches and the LEDs S and T, and build your design. When the lab table matches yours, go to Real chip to get the connection list.

▶ Open the lab in Build

How it is assessed

The grade comes from 5 dimensions. The LEDs lighting up is one fifth: what is mainly valued here is that the design is correct and simple, and that you can explain why.

Dimension
Weight
What is assessed
📋 Tables and functions
20%
Both tables are complete and in order, and the functions come from them.
✂️ Simplified design
20%
The functions are simplified, the two outputs share what they can and the diagram uses the symbols correctly.
🎮 Checked simulation
20%
The lab circuit gives the same tables as yours in all 16 combinations.
🔧 Assembly
20%
The chips are powered correctly, the inputs have their resistor to ground, the leftover ones are connected to ground and the circuit works.
🎤 Report and presentation
20%
The report makes sense on its own, says what failed and how you fixed it, and you explain why night irrigation saves water.
▸ Check your design

Before building

Four questions to know if you are on track. Answer them after phase 2.

1. In the irrigation table (H, R and D, eight rows), in how many rows is the output W equal to 1?

rows

2. What function does the window have?

3. Which gate can the irrigation and the window share?

4. Sharing that NOT, the circuit has 2 NOTs and 3 two-input ANDs. How many 74HC chips do you need?

chips
⊕ For those who finish early

5. The person who looks after the garden adds a rule: in the daytime, the window also opens if the soil is wet (H = 0), so that it dries and mold does not appear; but never if it is raining. Write the new function of V (it now depends on all four inputs) and simplify it with the 4-variable Karnaugh map in the lab.

The window opens “if it is not raining and (it is hot, or it is daytime with wet soil)”: V = R̅ · T + R̅ · D · H̅, which can also be written V = R̅ · (T + D · H̅). On the 4-variable map there are two groups: one of four cells (R̅·T) and one of two (R̅·D·H̅). It needs one more NOT (the one for H) and an OR to join the two products: a 74HC32.
⊕ Check it in the lab

Open Karnaugh with 4 variables, mark the ones of your new table and make the groups: the lab tells you if there are too many or too few.

▶ Open the 4-variable Karnaugh map

If you have time left, replace a switch with a real sensor. An LDR with a resistor forms a voltage divider, which is analog: for the chip to read a clear 0 or 1 you need a transistor or a comparator, as in the electronics unit for ages 14-15. That way sensor D really detects whether it is daytime.