← IGCSE Computer Science Paper 1

Magnetic field sensor

An input device that detects the presence and strength of a magnetic field. Used in door alarms, compasses, wheel speed counters and metal detectors.

Understanding Magnetic field sensor in IGCSE Computer Science Paper 1

What it does: When the door opens, the magnet moves away and the field strength drops, so the alarm is triggered. Metal near the detector changes the magnetic field, and the high reading makes the output device beep. A magnetic field sensor captures magnetic field strength. Light sensors are the ones that measure brightness. Each time the magnet passes the sensor it gives a signal. The microprocessor counts the signals per second to calculate speed. Sensors capture data from the environment and send it as input. Output devices such as screens are what display information. This is the name of the sensor and describes what it detects, which is the core idea of the module.

Common mistakes: When the door opens, the magnet moves away and the sensor reads a weak field. The alarm must turn ON, so the line should be alarm ← ON. A strong field means the magnet is next to the sensor, so the window is closed. This line should output "Window closed".

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 283–292) and word search (Modules 283–303).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does a magnetic field sensor detect?
The presence and strength of a magnetic fieldThe brightness of light in a room
Matches
A magnetic field sensor measures the temperature of a room
↓
A magnetic field sensor does not measure temperature. It detects the presence and strength of a magnetic field. A temperature sensor measures temperature.
Applying
Meanings
Term
magnetic field sensor
Meaning
An input device that detects the presence and strength of a magnetic field. Used in door alarms, compasses, wheel speed counters and metal detectors.
Practice
WHILE alarmSet = TRUE DO
Testing
Gaps
strength ← (magneticSensor)
Check Answer
Spots
2IF field < 10 THEN
3 alarm ← OFF

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Viperfish' badge — Deep Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does a magnetic field sensor detect?
A. The presence and strength of a magnetic field ✓
B. The brightness of light in a room
A magnetic field sensor captures magnetic field strength. Light sensors are the ones that measure brightness.
2. A door alarm has a magnet on the door and a sensor on the frame. What happens when the door opens?
A. The sensor detects a stronger field, so the alarm switches off
B. The sensor no longer detects the magnet's field, so the alarm can sound ✓
Moving the magnet away makes the field weaker or lost. The microprocessor sees this change and triggers the alarm.
3. Which use of a magnetic field sensor is correct?
A. A compass measuring the temperature of the air
B. A compass finding the direction of the Earth's magnetic field ✓
A compass uses a magnetic field sensor to detect the Earth's magnetic field and work out which way is north.
4. How can a magnetic field sensor help measure the speed of a wheel?
A. It counts the pulses each time a magnet on the wheel passes by ✓
B. It measures how hot the wheel gets as it spins
Each time the magnet passes the sensor it gives a signal. The microprocessor counts the signals per second to calculate speed.
5. Which device uses a magnetic field sensor to find buried metal?
A. A metal detector ✓
B. A barcode scanner
A metal detector senses changes in the magnetic field caused by metal objects. A barcode scanner reads patterns of light.

Match the Pairs

magnetic field sensor → An input device that detects the presence and strength of a magnetic field
magnetic field strength → The data captured by a magnetic field sensor, which is sent to the microprocessor
A door alarm uses a magnetic field sensor to detect when a magnet on the door moves away from the frame → IF magnetic_sensor < 5 THEN sound_alarm()
A metal detector uses a magnetic field sensor to detect a change in the magnetic field caused by metal → IF field_strength > 80 THEN beep()
A magnetic field sensor measures the temperature of a room → A magnetic field sensor does not measure temperature. It detects the presence and strength of a magnetic field. A temperature sensor measures temperature.
Wheel speed counter: sensor detects light from the wheel → A wheel speed counter uses a magnetic field sensor to detect a magnet on the wheel passing by each turn, not light.

Key Term

magnetic field sensor
An input device that detects the presence and strength of a magnetic field. Used in door alarms, compasses, wheel speed counters and metal detectors.

Fill in the Blanks

1. strength ← READ(magneticSensor)
Hint: Type the keyword that gets a value from the sensor and stores it in a variable.
2. heading ← READ(compassSensor) OUTPUT heading
Hint: Type the keyword that shows a value on the screen.
3. IF fieldStrength < 10 THEN alarm ← ON ENDIF
Hint: Type the operator meaning the magnetic field is weaker than the limit, so the door magnet has moved away.
4. IF magnetDetected = TRUE THEN rotations ← rotations + 1 ENDIF
Hint: Type the variable that counts each wheel turn.
5. IF strength > 80 THEN OUTPUT "Metal found" ENDIF
Hint: Type the keyword that starts the code that runs when a strong field is found.

Spot the Error

Question 1
A field ← READ(magSensor)
B IF field < 10 THEN
C alarm ← OFF
D ENDIF
Line C — When the door opens, the magnet moves away and the sensor reads a weak field. The alarm must turn ON, so the line should be alarm ← ON.
Question 2
A field ← READ(magSensor)
B IF field >= 10 THEN
C OUTPUT "Window open"
D ELSE
E OUTPUT "Window open"
F ENDIF
Line C — A strong field means the magnet is next to the sensor, so the window is closed. This line should output "Window closed".
Question 3
A field ← READ(magSensor)
B heading ← DIRECTION(light)
C OUTPUT heading
Line B — A compass works out direction from the magnetic field reading. The variable light does not exist, so it should be DIRECTION(field).
Question 4
A count ← 0
B IF READ(magSensor) < 5 THEN
C count ← count + 1
D ENDIF
Line B — A magnet on the wheel gives a strong field each time it passes the sensor. The condition should test for a strong reading (> 50), not a weak one.
Question 5
A baseline ← 20
B field ← READ(magSensor)
C IF field > baseline THEN
D SOUND(keyboard)
E ENDIF
Line D — A metal detector gives a sound alert through an output device. A keyboard is an input device, so it should be SOUND(speaker).

Student with a class code? Join your class →