Lesson 4 - AI Exploration: Motion Detection
Students learn how motion detection works and build a program that counts how many people walk past.
I can explain how motion detection works.
I can set the AI camera to motion detection mode and choose a sensitivity level.
I can build a program that counts how many people walk past.
1. Engage: Let's play a quick game
Switch the AI camera to motion detection mode. One student stands in front of the camera. When they move, the indicator light turns on; when they stand still, it turns off.

Key Question
What is the camera really reacting to—your face, or your movement?
It reacts to movement; when you stand still, nothing changes—even with your face straight toward the camera.
Motion detection is a way for a camera to notice when part of the picture changes from one moment to the next. It compares two frames and looks for the pixels that are different.
2. Explore: How Does the Camera “See” Movement?
Open the interactive website on the computer (shown below):

The website shows three pictures: the previous frame (A), the current frame (B), and the difference between them. Moving the Time slider makes the scene move; only the parts that change light up in the difference frame.

Activity 1
Have students open the interactive website and look at the three panels: Previous Frame A, Current Frame B, and Difference A−B.
Have students drag the Time slider and watch which parts light up in the Difference panel.

Have students change the Sensitivity slider and observe how the light, medium and strong wind levels are detected differently.


Have students answer the three quiz questions.

Key Question
What makes the camera decide that something is moving? How does the sensitivity setting change this?
Expected answer: the camera compares two frames and counts the pixels that changed. No change means no motion. A higher sensitivity catches smaller movement, but it also catches noise, which causes false alarms.
3. Engineer: Set Up the Camera
Part 1: Connect the Hardware

Part 2: Learn the Camera Buttons
| Button | What it does |
Blue button![]() | Switch mode — choose motion detection |
White button![]() | Change sensitivity — 1 / 2 / 3 |
Explain what sensitivity means: it is how much the picture must change before the camera calls it movement. A higher sensitivity notices smaller changes—just like in the interactive website, where a high sensitivity even caught the light wind. A lower sensitivity reacts only to larger movement.
Teaching Note: switch to motion detection first, then set the sensitivity. The indicator light lets students see detection working before any programming.
4. Experience & Challenge: Catch and Count
Experience: find the right sensitivity
Activity 2
Guide students to assemble the camera module with building blocks so the camera stays at a fixed distance. For each sensitivity level, test three kinds of movement.
For example, moving a finger:



Watch the indicator light: does it turn on?
| Motion/Sensitivity | 1 | 2 | 3 |
| Move a single finger | |||
| Wave a hand | |||
| A person walks past |
Challenge: count the people
Have students write a program that counts how many people walk past.
Activity 3
Write a program that records how many people walk past and shows the number on the micro:bit screen.

Add the extension, then use the AI Motion Sense block.

Use a variable (count): each time motion is detected, add 1 and show the number.

Example code:

5. See More: Where Do We Use Motion Detection?
At home and in the city
Automatic doors open when they detect you moving toward them. Smart lights turn on when you walk past. Security cameras start recording when something moves—and some count how many people pass by, just like our Challenge.
In nature
Wildlife camera traps take a photo when an animal moves. Scientists use them to count animals and protect rare species, without standing there all day.
Key Question
Where would you use motion detection at home or at school? Why?
Motion detection helps us notice movement—but it can also make mistakes (false alarms), so we use it carefully.
Next lesson: Lesson 5










