Home / Units

Ages 15-16 · Technology · Digital electronics

Digital Electronics: Binary, Logic Gates and Chips, with a Simulator

Digital electronics works with just two states, 0 and 1. With them your phone stores numbers, photos and music, and tiny parts called logic gates make decisions: whether an alarm sounds, whether an elevator starts or whether a garden gets watered. In this unit for ages 15-16 you learn to count in binary, to read and design circuits with gates and to build them with real chips. It is one of the interactive Technology resources on SoyTecnoTeacher.

🔋 This page is the summary of the essentials. The complete interactive unit —six lessons with self-marking exercises, the logic gate lab built in, a twenty-two-question review and the greenhouse project— is one click away.

Open the interactive unit →

What is digital electronics?

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 gradually, like the temperature of a room or the voice picked up by a microphone. It is digital if it only takes certain values: in digital electronics, two. Each one is called a bit, and eight bits make a byte.

Inside a circuit, 0 and 1 are voltages. In chips powered at 5 V, anything between 0 and 1.5 V is read as a 0, and anything between 3.5 and 5 V as a 1. That is why a little noise does not ruin the data: a 1 that arrives at 4.2 V is still a 1. That is the reason almost everything is digital today.

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
Analog and digital, compared
AnalogDigital
Any value, no jumpsOnly two values: 0 and 1
The hand of a clock, the groove of a vinyl recordThe display of a clock, an MP3
Noise adds to the signal and cannot be removedA little noise does not turn a 0 into a 1
Each copy loses a littleA copy is identical to the original

Quick exercise

Which of these signals is digital?

The binary system

If there are only two digits, numbers are written in base 2. It works like the decimal system, but each position is worth twice the one to its right, instead of ten times more: 1, 2, 4, 8, 16, 32, 64, 128… Those values are called weights.

From binary to decimal, add the weights that have a 1 under them: 101101 = 32 + 8 + 4 + 1 = 45. From decimal to binary, subtract weights, from the biggest one that fits to the smallest (a 1 if it fits, a 0 if not), or divide by 2 and read the remainders from bottom to top: 37 gives 100101.

With n bits there are 2n combinations, from 0 to 2n − 1: with 4 bits, 16 numbers; with a byte, 256. And that same binary counting order is the one used to write the rows of truth tables. To practice, the interactive unit has a whole lesson on binary with six self-marking exercises.

Calculate

What decimal number is 10011?

Logic gates

A logic gate is a circuit that receives one or more inputs (0 or 1) and gives an output, also 0 or 1, following a fixed rule. The rule is written in its truth table, which lists all the possible combinations of the inputs, in binary counting order. The three basic ones can be understood with switches: the AND is two switches in series (both are needed), the OR, two in parallel (one is enough), and the NOT, a push button that switches off when pressed.

Logic gates: symbol, expression and when they give 1
SymbolGateExpressionThe output is 1…Chip
NOTS = Aif the input is 0: it flips it74HC04
ANDS = A·Bonly if all the inputs are 174HC08
ORS = A + Bif any input is 174HC32
NANDS = A·Bunless all are 174HC00
NORS = A + Bonly if all are 074HC02
XORS = A ⊕ Bif the inputs are different74HC86

The small circle on the output means negation: the NAND is an AND with its output flipped, and the NOR, an OR. Besides the American symbol (ANSI standard), which tells the gates apart by their shape, there is the European one (IEC), a rectangle with a sign inside: & for the AND, ≥1 for the OR, =1 for the XOR. Both symbols of each gate, with their table, are in the cheat sheet on the Map tab of the interactive unit.

The truth table of the AND
ABS = A·B
000
010
100
111
The truth table of the OR
ABS = A + B
000
011
101
111
The truth table of the XOR
ABS = A ⊕ B
000
011
101
110

Quick exercise

A workshop press only comes down if the operator presses two buttons at the same time, one with each hand. Which gate does it need?

From circuit to table

Analyzing a circuit means finding out what it does. It is read from left to right, writing the output of each gate, and at the end you have its logic function. Each gate has its own sign: the dot (·) for the AND, the plus (+) for the OR and a bar on top for the NOT. The order is the one from math: first the bars, then the products and finally the sums; if an OR has to be done first, it goes in parentheses.

This is the house alarm: A is the door, B the window and C the key that arms it. The first gate, an OR, gives A + B (“the door or the window is open”); the second, an AND, joins it with the key: S = (A + B)·C.

A1B0C11 · OR2 · ANDS

With three inputs, the table has 8 rows. It helps to put one helper column for each gate: that way each value comes from the previous one. The siren sounds in three rows: 011, 101 and 111. With the key removed (C = 0) it never sounds.

The truth table of the alarm, with the column for the OR gate
ABCA + BS = (A + B)·C
00000
00100
01010
01111
10010
10111
11010
11111

Logic expressions have their own rules, Boolean algebra: A·0 = 0, A + 1 = 1, A·A = 0, A + A = 1, and De Morgan’s laws, which say that when the bar is broken the sign changes: A·B = A + B. They are used to simplify a circuit before building it. You can check each one with truth tables in Free mode in the lab.

Calculate

A circuit gives S = A·B + C. Make its 8-row table: in how many rows is the output 1?

rows

From problem to circuit

Designing is the way back: start from what the circuit has to do, told in words, and arrive at the gates. The method always works, in six steps: 1) give a letter to the inputs and the output, saying what its 1 means; 2) fill in the truth table; 3) write the sum of products, one AND for each row with a 1, with the letter negated if it is 0 in that row; 4) simplify with the Karnaugh map; 5) draw the circuit and 6) check it row by row.

The classic example is the voter: three judges vote with a push button and the green light comes on when two or more vote yes. The output is 1 in rows 3, 5, 6 and 7. On the Karnaugh map, the AB columns go in the order 00, 01, 11, 10 so that two neighboring cells only differ in one letter, and the ones are grouped in rectangles of 1, 2, 4 or 8, as large as possible. Each group gives a product with the letters that do not change:

ABC00011110010001011101234567

There are three pairs, and the function becomes S = A·B + A·C + B·C: “it comes on if A and B vote yes, or A and C, or B and C”. Three two-input ANDs and two ORs:

ABC1 · AND2 · AND3 · AND4 · OR5 · ORS

Quick exercise

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. What function does it have?

The 74HC chips: the real gates

Gates are bought inside integrated circuits with 14 pins. In the 74HC family each type of gate has its own chip, and almost all of them hold four identical two-input gates; the one for NOTs, the 74HC04, holds six. To read it, put the notch on the left: pin 1 ends up at the bottom left and the count goes counterclockwise. Pin 14 (VCC) goes to +5 V and pin 7 (GND) to ground; without that, the chip does nothing.

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.

Each input goes to a switch that connects it to +5 V and to a 10 kΩ resistor to ground: without it, the input is left “floating” and the chip reads noise, even from your hand. Each output lights an LED with a 330 Ω resistor. And the unused inputs go to ground. Everything is built on a breadboard with three AA batteries or a 5 V USB cable.

+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

To know how many chips you need, count the gates of each type: the voter, with 3 ANDs and 2 ORs, fits in a 74HC08 and a 74HC32. The alarm, in another two: a 74HC32 for the OR and a 74HC08 for the AND.

Try it in the logic gate lab

All of the above is really understood when you light an LED. The logic gate lab has six modes: Build, to connect gates by tapping, with no dragging, and see the function and the truth table at the same time; The gates, with the seven cards; From problem to circuit, which takes you through the six design steps and checks each one; Karnaugh, to make the groups yourself; Practice, with three levels and a class mode for the digital whiteboard; and Real chip, which turns your circuit into 74HC chips with the connection list to build it.

Logic gate lab

Build circuits · see their truth table · turn them into chips

How to use it

To connect, tap an output (a switch or the tip of a gate) and then the input it goes to; to remove a wire, tap it. In class, what works best is to ask for the alarm table before pressing anything and then check it row by row: almost everyone gets the OR right and misses the row with the key removed. You can also open the simulator page full screen.

The project: the school garden greenhouse

In the Region of Murcia (Spain) water is scarce, and watering at midday is throwing it away: a good part evaporates before reaching the roots. The unit project is the brain of a greenhouse, made with logic gates. It has four sensors —dry soil (H), rain (R), daytime (D) and heat (T)— and two outputs: the irrigation opens when the soil is dry, it is not raining and it is night, and the roof window, when it is hot and it is not raining. It is designed in five phases (analyze, design, simulate, build and present), tested in the lab and built with a 74HC04 and a 74HC08, because the two outputs share the NOT of the rain. It is assessed with a rubric of five dimensions, and whoever finishes early can add one more rule with a four-variable Karnaugh map.

Quick exercise

“The window opens when it is hot, unless it rains”. What function does it have?

FAQ

What is digital electronics?

It is the part of electronics that works with signals of only two states, 0 and 1, which inside the circuit are two voltages: close to 0 V and close to 5 V. With them, numbers, letters, photos and sound are stored in binary, and logic gates make decisions. It is the basis of computers, phones and automatic systems.

What is the difference between an analog and a digital signal?

An analog one can take any value and changes gradually, like temperature or the voice. A digital one only takes two values, 0 and 1. Digital stands up better to noise, because a little disturbance does not turn a 0 into a 1, and it can be copied without losing quality.

What is studied in digital electronics at ages 15-16?

Analog and digital signals, the binary system, logic gates (NOT, AND, OR, NAND, NOR and XOR) with their symbols and truth tables, how to get the function of a circuit, how to design a circuit from a problem with the sum of products and the Karnaugh map, and how to build it with chips from the 74HC family. It is the “basic digital electronics” topic of block B of the Technology curriculum in the Region of Murcia (Spain).

How do you convert a number from binary to decimal?

Write the weights under each digit, starting from the right: 1, 2, 4, 8, 16… and add up the ones that have a 1 above them. For example, 1101 = 8 + 4 + 1 = 13. For the opposite direction, subtract weights or divide by 2 and read the remainders from bottom to top.

What is a truth table?

It is a table with all the possible combinations of the inputs of a logic circuit and the output it gives for each one. With n inputs it has 2 to the power of n rows, written in binary counting order so that none is forgotten: with two inputs, 00, 01, 10 and 11.

What is the Karnaugh map for?

To simplify a logic function without doing algebra. It is the truth table placed in a grid where neighboring cells only differ in one letter. By grouping the ones in rectangles of 1, 2, 4 or 8 cells, each group gives a product with the letters that do not change, and the resulting circuit needs fewer gates.

Which chip holds each logic gate?

In the 74HC family: the 74HC00 holds four NANDs; the 74HC02, four NORs; the 74HC04, six NOTs; the 74HC08, four ANDs; the 74HC32, four ORs, and the 74HC86, four XORs. All of them have 14 pins, are powered through pin 14 (+5 V) and pin 7 (ground), and work between 2 and 6 volts.

Do you need lab equipment to do this unit?

Not to learn it: the unit includes the logic gate lab, which builds circuits on screen and turns them into chips with the connection list. For the project it helps to have a breadboard, a 74HC04, a 74HC08, four switches, resistors and two LEDs, very cheap material; if you do not have it, the whole assembly can be done in Real chip mode.

Open the complete interactive unit

Six lessons with self-marking exercises, the logic gate lab built in, a twenty-two-question review and the school garden greenhouse project.

Open the Digital Electronics unit →

Unit written by Jaime Aniorte, a Technology teacher at a secondary school in the Region of Murcia (Spain), who teaches this subject to 15-16 year olds and built the logic gate lab that goes with it. It follows the Technology curriculum for ages 15-16 of the Region of Murcia (BORM no. 283, block B: basic digital electronics).

Last updated: