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.
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.
Two ways of carrying information · 5 concepts
Any value: the hand of a clock
Only two values: 0 and 1
0 = near 0 V · 1 = near 5 V
1 bit = a 0 or a 1 · 1 byte = 8 bits
It resists noise and copies without losing anything
Counting with two digits · 4 concepts
128 · 64 · 32 · 16 · 8 · 4 · 2 · 1
1101 = 8 + 4 + 1 = 13
Subtract weights or divide by 2
With n bits, 2n combinations
The parts that decide · 7 concepts
All the possible inputs and their output
Flips it: 0 → 1 and 1 → 0
1 only if both are 1
1 if either is 1
A negated AND
A negated OR
1 if they differ
Reading and designing circuits · 5 concepts
· is AND, + is OR, the bar is NOT
The rules for simplifying
Inputs, outputs and when it turns on
One product for each row with a 1
Grouping ones to simplify
The real gates · 4 concepts
One chip for each type of gate
Pin 14 to +5 V and pin 7 to ground
Switch with resistor · LED with resistor
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 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.
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.
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.
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.
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 hands turn without jumping: analog. The numbers on a display change minute by minute: digital.
The groove of a vinyl record copies the sound wave: analog. An MP3 or streaming are millions of zeros and ones.
A dimmer that raises it little by little is analog. A switch, on or off, is digital.
The mercury line that rises is analog. The number that beeps, digital: inside, it stores the measurement in binary.
Inside a digital circuit, 0 and 1 are not written numbers: they are voltages. In the chips you will use, powered at 5 V:
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.
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.
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.
| Unit | Equals | Enough for… |
|---|---|---|
| 1 bit | a 0 or a 1 | knowing whether a push button is pressed |
| 1 byte (B) | 8 bits | one letter of a message |
| 1 kilobyte (kB) | 1,000 bytes | half a page of text |
| 1 megabyte (MB) | 1,000 kB | one minute of an MP3 song |
| 1 gigabyte (GB) | 1,000 MB | a short movie on your phone |
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.
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.
1. Which of these signals is digital?
2. Only one of these three signals is digital. Tap it.
3. Match each word with its meaning. Tap one on the left and then its partner on the right.
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?
5. Fill in the blanks:
6. You record a voice note and send it to a friend. Put the journey of your voice in order:
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.
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.
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:
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.
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:
1011012 = 32 + 8 + 4 + 1 = 45
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:
| Division | Quotient | Remainder |
|---|---|---|
| 37 : 2 | 18 | 1 |
| 18 : 2 | 9 | 0 |
| 9 : 2 | 4 | 1 |
| 4 : 2 | 2 | 0 |
| 2 : 2 | 1 | 0 |
| 1 : 2 | 0 | 1 ↑ |
From bottom to top: 37 = 1001012. Check it by adding weights: 32 + 4 + 1 = 37.
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:
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:
| Decimal | 4 | 2 | 1 |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 |
| 2 | 0 | 1 | 0 |
| 3 | 0 | 1 | 1 |
| 4 | 1 | 0 | 0 |
| 5 | 1 | 0 | 1 |
| 6 | 1 | 1 | 0 |
| 7 | 1 | 1 | 1 |
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.
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.
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.
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?
4. Fill in the blanks:
5. Put these binary numbers in order from smallest to largest:
6. Match each binary number with its decimal number.
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.
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.
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.
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.
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.
Inverter
S = A (read “not A”)
| A | S = A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Flips the input: if 1 comes in, 0 comes out. It is a push button that switches off when pressed, like the fridge light.
Logical product
S = A·B («A y B»)
| A | B | S = A·B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
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.
Logical sum
S = A + B («A o B»)
| A | B | S = A + B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Gives 1 if any input is 1 (or both). Careful: in logic, 1 + 1 = 1. It is switches in parallel.
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.
Negated AND
S = A·B
| A | B | S = A·B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The opposite of the AND: gives 0 only if both are 1. Any other gate can be built with NANDs.
Negated OR
S = A + B
| A | B | S = A + B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
The opposite of the OR: gives 1 only if both are 0. “Neither A nor B”.
Exclusive OR
S = A ⊕ B
| A | B | S = A ⊕ B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
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.
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.
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.
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:
Recognizing each gate by its symbol and by its table, and knowing which one to use in a problem.
1. Match each symbol with its name.
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?
| A | B | S |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
4. Fill in the blanks:
5. An AND gate with three inputs (A, B and C): how many rows does its truth table have?
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.
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.
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.
Each gate has its own sign, like the operations in math:
| Gate | Written | Read |
|---|---|---|
| AND | A·B | A and B (a dot, like multiplying) |
| OR | A + B | A or B (a plus, like adding) |
| NOT | A | not A (a bar on top) |
| NAND | A·B | the bar covers the whole AND |
| XOR | A ⊕ B | A 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).
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.
With the door open (A = 1), the window closed (B = 0) and the alarm armed (C = 1), the LED lights up.
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.
| A | B | C | A + B | S = (A + B)·C |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
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 AND | With OR | What it says |
|---|---|---|
| A·0 = 0 | A + 1 = 1 | a 0 cancels the AND; a 1 fills the OR |
| A·1 = A | A + 0 = A | the 1 in an AND and the 0 in an OR change nothing |
| A·A = A | A + A = A | repeating adds nothing (here 1 + 1 = 1) |
| A·A = 0 | A + A = 1 | something and its opposite |
| A·B = A + B | A + B = A·B | De 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.
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.
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.
Going from the circuit to the expression, from the expression to the table, and using the first rules of Boolean algebra.
1. The seat belt beep: A is the engine on and B, the seat belt fastened. What expression does this circuit have?
2. This other circuit gives S = A·B + C. Make its truth table (8 rows): in how many rows is the output 1?
3. Put the steps for analyzing a circuit in order:
4. Complete the rules:
5. By De Morgan's laws, what is A·B equal to?
6. Match each expression with what it says in words. Pay attention to the parentheses.
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.
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.
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.
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:
| A | B | C | S = A·B + A·C + B·C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
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.
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:
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:
The design method, the sum of products and the Karnaugh groups.
1. Put the steps for designing a circuit from a problem in order:
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?
| A | B | S |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
4. Complete the rules of the Karnaugh map:
5. These four ones form a single group of four. What simplified function does it give?
6. When you read a problem, each word tells you a gate. Match them.
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.
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.
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.
| Chip | Holds | Note |
|---|---|---|
| 74HC00 | 4 NAND gates | any other gate can be made with NANDs |
| 74HC02 | 4 NOR gates | it has a different pinout: the output comes before the inputs |
| 74HC04 | 6 NOT gates | six, not four |
| 74HC08 | 4 AND gates | |
| 74HC32 | 4 OR gates | |
| 74HC86 | 4 XOR gates |
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:
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.
Everything is built on a breadboard, with the chip straddling the central channel, so that each pin ends up in its own column.
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.
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.
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.
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.
Reading a pinout, counting chips and connecting the inputs and outputs properly.
1. You are going to power the 74HC08. Which pin goes to the + of the 5 V? Tap it.
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?
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?
5. Match each chip with what it holds.
6. Fill in the blanks:
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.
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?
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.
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?
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?
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?
11. What expression does this circuit have?
12. With that same circuit, in how many of the 8 combinations does the LED light up?
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?
14. Using Boolean algebra, simplify S = A·B + A·B.
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?
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.
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?
19. In your component box only one 74HC04 is left. How many different signals can you negate with it?
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?
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.
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.
| Letter | Sensor | It is 1 when… | In the lab |
|---|---|---|---|
| H | soil humidity | the soil is dry | switch A |
| R | rain | it is raining | switch B |
| D | light (an LDR) | it is daytime | switch C |
| T | temperature | it is hot (above 28 °C) | switch D |
| W | output: watering | the drip solenoid valve opens | LED S |
| V | output: the window | the motor opens the roof window | LED T |
And these are the two rules given by the person who looks after the garden:
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.
A 400-point breadboard and colored wires: red for +5 V, black for ground.
The NOTs and the ANDs. If your design has any OR, a 74HC32 as well.
They act as sensors. A four-position DIP switch works very well. Each one with its 10 kΩ resistor to ground.
Blue for the irrigation and red for the window.
A three-AA battery holder (4.5 V) or a 5 V USB cable.
To check the design before building and to get the connection list.
⏱ 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.
⏱ 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.
⏱ 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.
⏱ 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.
⏱ 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.
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 BuildThe 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.
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?
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?
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.
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 mapIf 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.