Sensor readings and selection – Year 8 Computing lesson
Pupils learn to read a sensor inside a loop and use if/elif/else with a threshold so a micro:bit responds in real time.
Lesson 3 of 6 in unit 8.6 Physical Computing, taught in Year 8, Summer 2. It answers one big question: How can a device decide when to respond to a reading?
By the end, pupils can read a sensor inside a loop and use if/elif/else with a threshold so a micro:bit responds in real time.
- The Build (the main task)
- Write a Plant Buddy program that reads the light level in a loop and shows a sad face when it is below a threshold of 60, and a happy face otherwise.
- Support version
- Part-filled code: the loop and the reading line are given; pupils fill in the comparison, the threshold and the two faces.
- Challenge
- Add an elif that scrolls COLD when the temperature is below 12, and explain why the order of the tests matters.
- Real-world link
- Plant Buddy reads the light level and the temperature over and over, and warns the gardening club when a plant is too dark or too cold.
- Key words
- Threshold, Real-time and Respond, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “The threshold is the sensor reading”; “Reading the sensor once before the loop is enough – the variable updates itself”.
- National Curriculum
- NC3 (two or more languages, at least one textual; data structures; modular programs with procedures or functions); NC5 (hardware and software components and how they communicate with each other and other systems).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils need computers for the main task.
Also sold in the Physical Computing unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for KS3 Computing
See allPupils learn to name the sensors and actuators in a smart device, say what each one detects or does, and show how they link through a processor.
Free sample lessonPupils learn to write a micro:bit program in Python that uses a while True loop to keep checking its buttons and control what the display shows.
Pupils learn to model a control system as a flowchart with a feedback loop, and choose which real-world details to keep or leave out.
Written for the specifications named. Not endorsed by or affiliated with any exam board.