Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Controlling with conditions

      Lesson details

      Learning outcome

      I can write a program which contains a conditional loop.

      Key learning points

      1. Conditions are either True or False.
      2. A conditional loop repeats a chunk of code until a condition is met.
      3. Microcontrollers can be programmed to respond to inputs.

      Keywords

      • Condition - a statement that can be either True or False

      • Conditional loop - a chunk of code that repeatedly runs a section of the program until a condition is met

      Common misconception

      A condition can have multiple possible answers.

      A condition must always be either True or False in a program.

      Teacher tip

      Model how to connect and use a push button switch with the Crumble controller, as this is key to enabling pupils to use inputs in their programs.

      Equipment

      Pupils will need access to a microcontroller, crocodile clips, battery packs, Sparkle LEDs and push button switches. Examples in this lesson use Crumble https://oak.link/crumble

      Licence

      This content is © Oak National Academy Limited (2026), licensed on Open Government Licence version 3.0
      except where otherwise stated. See Oak's terms & conditions
      (Collection 2).

      Lesson video

      Loading...

      Prior knowledge starter quiz

      6 Questions

      Q1.
      What is an algorithm?

      a type of electrical motor
      a component of a microcontroller
      a random set of instructions
      Correct answer: a precise sequence of instructions to complete a task

      Q2.
      What is an infinite loop?

      Correct answer: a sequence of instructions that repeats forever
      a loop that runs exactly 10 times
      a machine that generates electricity
      a tool used to draw algorithms

      Q3.
      What does a count-controlled loop do?

      runs forever without stopping
      Correct answer: repeats a section of a program a specific number of times
      stores data in a microcontroller
      converts energy into motion

      Q4.
      What is the name of the Crumble output component that emits light and can shine in different colours?

      Correct Answer: Sparkle, sparkle

      Q5.
      Arrange the steps for connecting components to a microcontroller:

      1 - select the components you want to connect
      2 - connect the components to the correct pads on the microcontroller
      3 - write the program to control the components
      4 - test the setup to ensure everything works

      Q6.
      What is an example of an output component?

      Correct answer: a motor
      a loop
      an algorithm
      a sequence

      6 Questions

      Q1.
      Match the terms to their definitions:

      Correct Answer:condition,a statement that can be either True or False

      a statement that can be either True or False

      Correct Answer:conditional loop,code that repeatedly runs until a condition is met

      code that repeatedly runs until a condition is met

      Correct Answer:microcontroller,a small computer that can respond to inputs and execute code

      a small computer that can respond to inputs and execute code

      Correct Answer:input,a signal or data received by the microcontroller

      a signal or data received by the microcontroller

      Q2.
      Arrange the steps for programming a microcontroller to respond to inputs:

      1 - connect the input device to the microcontroller
      2 - write the code to handle the input
      3 - upload the program to the microcontroller
      4 - test the program by using the input device

      Q3.
      What is a condition in programming?

      a type of loop
      a block of code that never runs
      Correct answer: a statement that can be either True or False
      a microcontroller component

      Q4.
      What does a conditional loop do?

      runs a program forever
      Correct answer: repeats a chunk of code until a condition is met
      converts electrical energy to mechanical energy
      stores data in a microcontroller

      Q5.
      Which of these is using a condition controlled loop?

      Correct answer: do until button pressed
      repeat 10 times
      wait 0.5 seconds
      set Sparkle to red

      Q6.
      What does True mean in a condition?

      the loop runs indefinitely
      the program stops
      the condition is not met
      Correct answer: the condition is met

      To help you plan your 5 computing lesson on: Controlling with conditions, download all teaching resources for free and adapt to suit your pupils' needs...