Comparing a sensor reading with a stored value
A pre-set value, such as a target temperature, kept in the microprocessor. It compares each digital sensor reading with it to decide if the reading is too high, too low or on target.
Understanding Comparing a sensor reading with a stored value in IGCSE Computer Science Paper 1
What it does: The stored value is set by the designer. Here it is held in a variable called targetTemp and the program compares each reading with it. 18 is lower than the target of 22, so the reading is too low. The microprocessor would switch the heater on. The microprocessor runs a stored program of instructions. The actuator only carries out the action it is told to do. The readings are compared continuously, so the system can respond whenever the reading drifts away from the target.
Common mistakes: The stored value is pre-set by the designer, so it must be a fixed number such as 22. It must not be copied from the sensor reading. The line should be target ← 22. The reading 25 is higher than the stored value 22, so the room is too hot. The microprocessor should switch the cooler on, not the heater. The line should be OUTPUT "Cooler on".
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 553–577) and word search (Modules 553–607).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
stored valueFill in the Blanks
Spot the Error
Student with a class code? Join your class →