Logic & Digital Control

N5 Engineering Science · Booklet 4a

← Back to N5 Engineering Science

What this topic is

Digital systems work with two states, 1 and 0. Logic gates combine them to make decisions: AND, OR and NOT.

You show what a circuit does with a truth table. You write it as a Boolean expression. You build it on the logic board or in Yenka. Microcontrollers and flowcharts are on the Programmable Control (Booklet 4b) page.

Slides and resources

Every lesson's slides, with and without answers.

Section 1 · Lesson 1

Digital signals and logic states

An analogue signal can take any value in a range. A digital signal has only two values: logic 1 (high, on, true) and logic 0 (low, off, false).

A dimmer and a light switch

Both control a lamp. A dimmer can set any brightness: that is analogue. A light switch is on or off: that is digital.

A dimmer switch with a round knob, mounted on a wall beside a light switch.
Photo: Paolomarco, CC BY-SA 4.0, via Wikimedia Commons

Analogue signals

Can take any value in a range. Change smoothly.

An LDR divider: Vout rises as it gets darker.

An LDR voltage divider and a graph of its output voltage against time: a smooth curve that rises and falls. Analogue Signals Can take any value in a range. Changes smoothly . LDR divider: V out rises as it gets darker . R LDR +5 V 0 V V out time (s) voltage (V) 0

Digital signals

Only two values: ON or OFF, HIGH or LOW, 1 or 0.

A push switch is digital: pressed or not.

  • Pressed: near 5 V, logic 1 (high, on, true).
  • Released: near 0 V, logic 0 (low, off, false).
A graph of voltage against time for a digital signal: it jumps between 0 V and 5 V, with nothing in between. Digital Signals Only two values . ON or OFF , HIGH or LOW , 1 or 0 . A push switch : pressed or not. time (s) voltage (V) 5 0

Digital inputs and outputs

Inputs give 1 or 0: push button, limit switch, guard switch, infrared sensor.

Outputs are on or off: LED, buzzer, motor, relay.

Circuit symbols for a switch, LED, buzzer, motor, relay and lamp. Digital Inputs and Outputs Inputs give 1 or 0 : push button, limit switch, guard switch, infrared sensor. Outputs are on or off : LED, buzzer, motor, relay. switch LED buzzer M motor relay lamp

Task: logic 1 or logic 0?

Tap the logic state for each situation. Every answer tells you why.

Booklet Task 1, p.4

1. State the logic state. A switch is being pressed.

2. State the logic state. A switch is not being pressed.

3. State the logic state. A guard sensor detects the guard is in place.

4. State the logic state. A buzzer is silent.

5. State the logic state. A motor is running.

Practice — exam style

1. Describe the difference between an analogue and a digital signal. 2 marks

Answer
An analogue signal can take any value in a range (1). A digital signal has only two values, 1 or 0 (1).

2. Explain why a digital signal is not upset by a small amount of noise. 2 marks

Answer
It has only two levels, far apart (1), so a little noise can't flip a 1 into a 0 (1).
Section 2 · Lesson 2

AND, OR and NOT gates Exam

A logic gate takes digital inputs (1 or 0) and gives one digital output, Z. At National 5 you use three: AND, OR and NOT.

Past papers 2024 S1 Q1(a), (b)

The exam calls the output Z. Your booklet calls it Q.

AND gate

Z = 1 only when all inputs are 1.

Like two switches in series.

Use: the two-hand press: it moves only when both hands are on the buttons.

The AND gate symbol: inputs A and B on the left, output Z on the right.ABZ
ABZ
000
010
100
111
Two push switches A and B in series with a lamp and a cell. Both must be pressed to light the lamp.AB

OR gate

Z = 1 when any input is 1.

Like two switches in parallel.

Use: an alarm that sounds when any door opens.

The OR gate symbol: inputs A and B on the left, output Z on the right.ABZ
ABZ
000
011
101
111
Two push switches A and B in parallel, in series with a lamp and a cell. Either one lights the lamp.AB

NOT gate

One input. The output is the opposite.

Also called an inverter.

Use: a fridge light that is on when the door is not closed.

The NOT gate symbol: one input on the left, the output Z on the right, with a small circle at its tip.AZ
AZ
01
10

Drawing the symbols

  1. Draw the shape.
  2. Add the input lines.
  3. Add the output line.
Watch out: draw the lines. A shape on its own scores 0. The inputs and output drawn score the mark. In 2024, only 59% of pupils in Scotland got this right.

The mistake: 0 marks

An AND gate shape on its own, with no input or output lines.

The answer: 1 mark

An AND gate with its two input lines and its output line drawn.

Task: name the gate

Tap AND, OR or NOT. Every answer tells you why.

1. Name the gate. It has this truth table. Z column: 0, 0, 0, 1

2. Name the gate. It has this truth table. Z column: 0, 1, 1, 1

3. Name the gate. It has only one input.

4. Name the gate. A machine runs only when the guard is closed and the start button is pressed.

5. Name the gate. A bell rings when the front door or the back door opens.

6. Name the gate. It changes a high input to a low output.

Testing a gate

Put a switch on every input and label them A and B. Switch up = 1. LED on = 1.

Test 00, 01, 10, 11 in order, then compare with the truth table.

In class you build it on the logic board: switches J and K are A and B. No kit? Do the same test in Yenka.

Safety: never join two outputs.

Testing a gate: switch A and switch B from +5 V into an AND gate. Its output Z lights an LED to 0 V.+5 V0 VABZ The logic section of the Logic and Arithmetic board: switches J, K and L on the left, two rows of AND, OR and NOT gates, and output LEDs X, Y and Z on the right.
The logic board, drawn from the UKESF / University of Southampton Logic and Arithmetic kit.
Practice — exam style

1. State the output of an AND gate when A = 1 and B = 0. 1 mark

Answer
0. AND needs both inputs at 1.

2. Draw the symbol for an OR gate. 1 mark

Answer
The OR gate symbol with inputs A and B and output Z.ABZ

Draw both input lines and the output line, or the mark is lost.

3. Describe what a NOT gate does. 1 mark

Answer
Its output is the opposite of its input (it inverts).
Section 3 · Lesson 3

Truth tables for combinations Exam

A truth table shows the output for every set of inputs. Work it out one gate at a time. Give each gate's output its own column, D and E. Do Z last. Each column scores a mark.

Past papers 2026 S2 Q14(d) 2025 S2 Q11(c) 2024 S2 Q14(c) 2023 S2 Q12(f) 2022 S2 Q12(a) 2021 S2 Q8(e) 2019 S2 Q9(e) 2018 S2 Q12(a)(ii) · asked in 8 of 8 exam years

How many rows?

Rows = 2n

n is the number of inputs.

  • 1 input: 2 rows
  • 2 inputs: 4 rows
  • 3 inputs: 8 rows
1 input: 2 rows
A
0
1
2 inputs: 4 rows
AB
00
01
10
11

Filling the input columns

  • C column: 0 1 0 1 0 1 0 1
  • B column: 0 0 1 1 0 0 1 1
  • A column: 0 0 0 0 1 1 1 1

This is counting in binary, from 000 to 111. Fill them this way and no row is missed. The exam always prints them in this order.

3 inputs: 8 rows
ABC
000
001
010
011
100
101
110
111

One gate at a time

A logic circuit has no memory. The output depends only on the inputs now.

Label each gate's output: D, E. Give each one a column. Do Z last, from D and E.

The exam uses D and E for these points and Z for the output. Your booklet calls them X and Q. They mean the same thing.

Logic diagram: A into a NOT gate gives D. B and C into an OR gate give E. D and E go into an AND gate. Its output is Z.ABCDEZ

Worked example: one column at a time

Complete the truth table for the logic diagram. 3 marks

  1. Column D = NOT A. 1 mark
  2. Column E = NOT B. 1 mark
  3. Column Z = D AND E. 1 mark

Each column scores its own mark. If D is wrong, Z can still score if it is right from your D.

Logic diagram: A into a NOT gate gives D. B into a NOT gate gives E. D and E go into an AND gate. Its output is Z.ABDEZ
ABDEZ
00111
01100
10010
11000
Press the button to fill one column at a time.

Task: fill the truth table

Tap a cell to set it: – then 0 then 1. Do column D first, then E, then Z. Then press Check.

Logic diagram: A and B go into an AND gate, giving D. C goes into a NOT gate, giving E. D and E go into an AND gate. Its output is Z.ABCDEZ
ABCDEZ
000
001
010
011
100
101
110
111
    Watch out: one column per gate. Jumping straight to Z loses the D and E marks, and a slip can't be found. Fill D, then E, then Z.
    Practice — exam style Booklet p.13

    1. State how many rows a truth table needs for 3 inputs. 1 mark

    Answer
    8 rows (23 = 8).

    2. State the row that comes after 1 0 1. 1 mark

    Answer
    1 1 0.

    3. Explain why D and E are given their own columns. 1 mark

    Answer
    Each column scores its own mark, so a slip in one column does not lose them all.

    From a real paper: 2021 Section 2, Question 8(e). 3 marks

    Exam question: part of a logic diagram for a camera flash unit. A and B go into an AND gate, giving D. B and C go into a second AND gate, giving E. D and E go into an OR gate, giving Z. Part (e) asks you to complete the D, E and Z columns of an 8-row truth table for inputs A, B and C.
    Marking instructions
    Marking instructions for 2021 Question 8(e): the D, E and Z columns, 1 mark for each correct column, follow-through error allowed.

    1 mark for each correct column. FTE (follow-through error) means a later column can still score if it is right from your earlier, wrong one.

    Sources & credits: © Qualifications Scotland (SQA). 2021 National 5 Engineering Science Section 2, Q8.

    Section 4 · Lesson 4

    Boolean expressions Exam

    A Boolean expression writes a whole circuit in one line. AND is a dot, OR is a plus, NOT is a bar over the letter. Brackets show which gates come first.

    Past papers 2026 S1 Q5 2025 S2 Q11(d) 2024 S2 Q12(c) 2023 S1 Q3 2022 S2 Q12(b) 2021 S2 Q8(f) 2019 S1 Q6 2018 S1 Q9 · asked in 8 of 8 exam years

    Boolean for each gate

    • AND is a dot: A • B
    • OR is a plus: A + B
    • NOT is a bar: A̅

    Your booklet writes AND as A.B and the output as Q. The exam writes A • B and Z.

    Z = A • BAND gate, inputs A and B, output Z.ABZAND is a dot
    Z = A + BOR gate, inputs A and B, output Z.ABZOR is a plus
    Z = A̅NOT gate, input A, output Z.AZNOT is a bar

    From words to Boolean

    A motor turns on when the start button is pressed and the guard is in place.

    1. Name the inputs: A = start button, B = guard.
    2. "and" means AND: a dot.
    3. Z = A • B
    AND gate: A is the start button, B is the guard, Z is the motor.ABZ

    From a diagram to Boolean

    1. Label each first gate: D, E.
    2. Write each one: D = A • B, E = C̅.
    3. The last gate joins them: Z = D + E.
    4. Put brackets round each first gate: Z = (A • B) + C̅
    A and B into an AND gate, giving D. C into a NOT gate, giving E. D and E into an OR gate, giving Z.ABCDEZ

    From Boolean to a diagram

    Draw Z = A̅ + (B • C).

    1. A, B, C on the left. Z on the right.
    2. The bracket first: B • C is an AND gate.
    3. A̅ is a NOT gate.
    4. The + outside the bracket is the last gate: OR.

    Draw every input and output line. A gate with a line missing loses its mark.

    A into a NOT gate. B and C into an AND gate. Both outputs into an OR gate, giving Z.ABCDEZ

    Task: match the expression to the diagram

    Choose the Boolean expression for each diagram. Find the first gates (the brackets) before the last gate. Then press Check.

    Diagram 1

    Diagram 1: A into a NOT gate; B and C into an OR gate; both into an AND gate, output Z.ABCDEZ

    Diagram 2

    Diagram 2: A and B into an AND gate; that and C into an OR gate, output Z.ABCZ

    Diagram 3

    Diagram 3: B and C into an AND gate; A and that into an OR gate, output Z.ABCZ

    Diagram 4

    Diagram 4: A and B into an OR gate; C into a NOT gate; both into an AND gate, output Z.ABCDEZ

    Watch out: keep the brackets. (A • B) + C and A • (B + C) are different circuits. Without brackets, A • B + C can be read either way.
    Practice — exam style Booklet pp.14–15

    1. Write the Boolean expression. A warning light comes on when a door is open (A) and the engine is running (B). 1 mark

    Answer
    Z = A • B

    2. Write the Boolean expression. A pump runs when no water is detected (A). 1 mark

    Answer
    Z = A̅

    3. Draw the logic diagram for Z = (A + B) • C. 2 marks

    Answer
    A and B into an OR gate. Its output and C into an AND gate, giving Z.ABCZ

    1 mark for each gate wired to the right inputs.

    From a real paper: 2019 Section 1, Question 6. 3 marks

    Exam question: the Boolean equation (A + B with a bar over B) • C = Z. Draw the logic diagram for this Boolean equation, between inputs A, B and C on the left and output Z on the right.
    Marking instructions
    Marking instructions for 2019 Question 6: a NOT gate on B; an OR gate on A and NOT B; an AND gate on that and C, giving Z. 1 mark for each gate wired correctly. No follow-through error from a gate.

    1 mark for each gate wired to the right inputs. No FTE from a gate: a gate wired wrongly loses the marks after it too.

    Sources & credits: © Qualifications Scotland (SQA). 2019 National 5 Engineering Science Section 1, Q6.

    Section 5 · Lesson 5

    Designing logic for engineering problems Exam

    To design a control system, underline the inputs and the output. Choose AND, OR or NOT. Write the Boolean. Then draw it and check it with a truth table.

    Past papers 2023 S2 Q12(g) 2019 S2 Q9(d)

    Worked example 1: a fan

    A fan runs when it is hot and the door is not open.

    1. A = hot, B = door open. Z = fan.
    2. AND, with NOT on B.
    3. Z = A • B̅
    4. Draw it, then check: is Z = 1 only when it is hot and the door is shut?
    A goes straight to an AND gate. B goes through a NOT gate to the same AND gate. Its output is Z.ABZ
    ABDZ
    0010
    0100
    1011
    1100
    D = B̅, Z = A • D. Z = 1 only in the shaded row.

    Worked example 2: a lift

    A lift moves when the door is closed and the floor or call button is pressed.

    1. A = door closed, B = floor button, C = call button.
    2. B OR C first, then AND with A.
    3. Z = A • (B + C)
    4. Check: the lift moves only with the door closed (A = 1).

    In class: you build this on the logic board and test all 8 rows. Switches J, K, L are A, B, C.

    B and C go into an OR gate. A and the OR output go into an AND gate. Its output is Z.ABCZ
    ABCDZ
    00000
    00110
    01010
    01110
    10000
    10111
    11011
    11111
    D = B + C, Z = A • D. Z = 1 only in the shaded rows.

    From a truth table to Boolean

    1. Find each row with Z = 1.
    2. AND its inputs, with a bar on each 0.
      • Row 0 1: (A̅ • B)
      • Row 1 0: (A • B̅)
    3. OR the brackets: Z = (A̅ • B) + (A • B̅)
    ABZ
    000
    011
    101
    110
    The rows with Z = 1 are shaded.

    Task: pick the gates for the problem

    Underline the inputs in your head, then pick. Every answer tells you why.

    1. Choose the gates. A drill runs only when the guard is down and the trigger is pressed.

    2. Choose the gates. A shop buzzer sounds when the front door or the back door opens.

    3. Choose the gates. A porch light comes on when it is not daylight.

    4. Choose the gates. A lift moves when the door is closed and the floor or the call button is pressed.

    5. Choose the gates. A fan runs when it is hot and the door is not open.

    Watch out: a bracket for every row. In 2023 only 37% of pupils in Scotland scored well on writing Boolean from a table. Write one bracket for each row with Z = 1, put a bar on every 0, then join them with +.
    Practice — exam style Booklet pp.21–22

    1. State the gate and write the Boolean. An alarm sounds when any one of three windows (A, B, C) is opened. 2 marks

    Answer
    OR (1). Z = A + B + C (1).

    2. Write the Boolean. A press works when the start button (A) and the guard (B) are on. The emergency stop (C) must not be pressed. 2 marks

    Answer
    Z = A • B • C̅

    3. Write the Boolean. A truth table has Z = 1 only in row A = 1, B = 1, C = 0. 2 marks

    Answer
    Z = A • B • C̅: one bracket, a bar on the 0.

    From a real paper: 2019 Section 2, Question 9(d). 3 marks

    Exam question: a logic circuit in a hospital bed has this truth table. A B Z: 0 0 1, 0 1 0, 1 0 0, 1 1 1. Part (d) asks you to complete the Boolean equation for output Z in terms of inputs A and B.
    Marking instructions
    Marking instructions for 2019 Question 9(d): Z = (A-bar • B-bar) + (A • B). 1 mark for each bracket, 1 mark for OR-ing them.

    One bracket for each row with Z = 1, a bar on each 0, then OR the brackets.

    Sources & credits: © Qualifications Scotland (SQA). 2019 National 5 Engineering Science Section 2, Q9.

    Booklet check

    Check your booklet work

    Answers to Booklet 4a. Try each one first, then open it. These use the booklet's letters, X and Q.

    Task 1 — Logic states (page 4)
    SituationLogic state
    A switch is being pressed.1
    A switch is not being pressed.0
    A guard sensor detects the guard is in place.1
    A buzzer is silent.0
    A motor is running.1
    Lesson 1 Review Questions
    1. Analogue: any value in a range. Digital: only two values.
    2. Any two: push button, limit switch.
    3. Any two: LED or lamp, buzzer.
    4. Near 5 V.
    5. Near 0 V.
    6. Logic 1.
    7. The guard is not in place.
    8. A buzzer sounds, to warn the user.
    9. It has only two levels, so noise can't flip it.
    10. Analogue.
    Lesson 2 Review Questions
    1. AND, OR, NOT.
    2. The output is 1 only when all inputs are 1.
    3. The output is 1 when any input is 1.
    4. The output is the opposite of the input.
    5. Q column: 0, 0, 0, 1.
    6. Q column: 0, 1, 1, 1.
    7. AND gate.
    8. OR gate.
    9. Logic 0.
    10. It inverts: the output is the opposite of the input.
    Practical Task 1 — Testing the gates (page 7)
    ABZ (AND)
    000
    010
    100
    111
    ABZ (OR)
    000
    011
    101
    111
    AZ (NOT)
    01
    10
    Task 4 — Truth tables (page 11)
    (a)
    ABXQ
    0011
    0100
    1011
    1101
    (b)
    ABXQ
    0010
    0111
    1000
    1100
    Task 5 — Three inputs (page 12)
    ABCXQ
    00000
    00101
    01000
    01101
    10000
    10101
    11011
    11111
    Lesson 3 Review Questions (page 13)
    1. Rows = 2n.
    2. 4.
    3. 8.
    4. The output depends on the inputs now only.
    5. One gate at a time, so mistakes are easy to spot.
    Task 6 — Words to Boolean (page 14)
    DescriptionBoolean
    Buzzer: either of two doorsQ = A + B
    Warning light: door open and engine onQ = A • B
    Pump off: no water detectedQ = A̅
    Heater: temperature low and timer onQ = A • B
    Task 7 — Drawing diagrams (pages 14 to 15)

    Check each diagram has every input and output line.

    • Q = A.B: one AND gate.
    • Q = A + B: one OR gate.
    • Q = A̅.B: A through a NOT gate, then AND with B.
    • Q = A + (B.C): B AND C first, then OR with A.
    Lesson 4 Review Questions
    1. Q = A • B
    2. Q = A + B
    3. Q = A̅
    4. Q = A • B • C̅
    5. Q = (A • B) + C
    6. Q = A + (B • C)

    Questions 5, 6, 7 and 10 are diagrams. Check them against the With Answers slides for Lesson 4.

    Task 8 — Design problems (pages 18 to 20)
    PartInputsBoolean
    (a)A front door, B back doorQ = A + B
    (b)A door closed, B startQ = A • B
    (c)A dark, B movementQ = A • B
    (d)A stop button (1 = not pressed)Q = A
    Lesson 5 Review Questions (pages 21 to 22)
    1. AND; Q = A • B
    2. OR; Q = A + B + C
    3. Q = A • B • C̅
    4. OR; Q = A + B
    5. AND (three inputs)
    6. AND
    7. Q = A • B
    8. Q = A̅ • B
    9. Q = (A • B) + C̅

    Question 10:

    ABCQ
    0000
    0010
    0100
    0111
    1000
    1011
    1100
    1111
    Check yourself

    Check yourself

    Mixed quiz

    Tap an answer. Every answer tells you why.

    1. Choose the right ending. A digital signal…

    2. Choose the right ending. An AND gate gives an output of 1 when…

    3. Choose the right ending. A truth table for three inputs needs…

    4. Choose the right ending. Z = A • B describes…

    5. Choose the reason. In a truth table, why give D and E their own columns?

    6. Choose the Boolean. A lamp is on when it is dark (A) and a switch (B) is not pressed.

    Rate your confidence: the I Can statements

    R not yet, A getting there, G confident. Saved on this device only.

    Recap

    Recap and words

    What loses marks

    • A gate shape with no input or output lines.
    • Jumping straight to Z: fill D, then E, then Z.
    • Input columns out of order: count in binary, 000 to 111.
    • Boolean with the brackets left out.
    • A bar missing, or on the wrong letter.
    • Writing Boolean from a table with a bracket missing for a row with Z = 1.

    Glossary

    Analogue signal
    Can take any value in a range. Changes smoothly.
    Digital signal
    Only two values: 1 or 0, on or off.
    Logic 1 / logic 0
    Logic 1 is high, on, true (near 5 V). Logic 0 is low, off, false (near 0 V).
    AND gate symbolABZ
    AND gate
    Output 1 only when all inputs are 1.
    OR gate symbolABZ
    OR gate
    Output 1 when any input is 1.
    NOT gate symbolAZ
    NOT gate (inverter)
    Output is the opposite of the input.
    Truth table
    Every set of inputs and its output. Rows = 2ⁿ.
    Boolean expression
    A circuit in one line: • for AND, + for OR, a bar for NOT.
    Two gates feeding a thirdABDEZ
    Combinational logic
    The output depends only on the inputs now. No memory.

    Where this comes up next

    Sources & credits: the text, logic diagrams, truth tables and the logic board drawing are by R Stewart, written for Booklet 4a; dimmer switch photo: Paolomarco, CC BY-SA 4.0, via Wikimedia Commons; the logic board is drawn from the UKESF / University of Southampton Logic and Arithmetic kit teacher guide. Past paper references, past paper questions and marking instructions © Qualifications Scotland (SQA). R Stewart - November 2026.