Lesson 5 - Farm Warehouse Monitoring

Lesson 5 - Farm Warehouse Monitoring

This project lesson brings together motion detection, the light strip and the buzzer. Students build a warehouse security system that can be armed and disarmed, then upgrade it so the light strip turns on as a fill light when it gets dark, letting the system keep watching at night.

image1.png I can explain why a security system needs arm and disarm modes.

image3.png I can use a variable to remember whether the system is armed.

image3.png I can use the light sensor to turn on the fill light when it is dark, and sound the alarm when motion is detected.


 

1. Engage: The Warehouse Needs a Guard

Open by describing the farm warehouse, full of tools and feed. When the farmer is away, someone could take things, and a camera alone cannot warn anyone. Ask the class: How can we build a security system that raises the alarm when someone enters, but stays quiet when the farmer is working there?

image5.png

Key Question

How can a security system watch the warehouse only when it is needed?

 

Expected answers: detect movement; sound an alarm; a switch to turn the alarm on and off.

Definition: A security system can be armed (on) or disarmed (off). When it is armed, it watches for intruders; when it is disarmed, it stays quiet so the farmer can work.


 

2. Explore: Meet the Parts and the Arm/Disarm Idea

Activity 1

Ask students to make the hardware connection, then switch the camera to motion detection mode. Have students choose the right sensitivity so that the indicator lights up when someone moves in front of the camera.

image6.png

Teacher note: Guide students to build a mounting spot for the light strip on the Lesson 4 block structure, make sure the light strip can give the camera effective lighting, and attach the light strip to the structure.

The AI camera detects movement, the LED light strip can light up, and the buzzer can sound (only the micro:bit above version 2). Together they make a security system.

 

Key Question

What should the system do when it is armed? When it is disarmed?

 

Expected answer: When armed and motion is detected, the buzzer sounds. At night, it also needs a fill light so the camera can see. When disarmed, the system stays quiet.


 

3. Engineer: Build the Security Program

Part 1: Plan the Algorithm (use a variable)

 

Key Question

How can the system remember whether it is armed?

 

The program uses a variable (flag) to remember the state. Students watch and learn.

image7.png

This is the program's pseudocode: set flag to 0 or 1. If A is pressed, the flag becomes 0 (disarmed). If B is pressed, the flag becomes 1 (armed). Inside the forever block, check the flag and run the matching action.

 

Part 2: Build the Complete Code

Open MakeCode and add the required Extensions.

image8.pngClick Extensions
image9.pngType boson and search
image10.pngClick the extension and go back to the coding page

Guide students to build the security program: create a variable (flag), add the A and B button blocks to set it, then add the alarm logic.

image11.png

Download the program and check the effect.

Press B to arm, then walk past → the buzzer sounds.

Press A to disarm, then walk past → the system stays quiet.

Teaching Note: Inside the forever loop, have students check the flag each time. If the flag is 0 (disarmed), the program does nothing. If the flag is 1 (armed), it watches for movement and sounds the alarm.


 

4. Experience & Challenge: Arm It and Keep Watching

Experience: test arm and disarm

Activity 2

Guide students to rebuild the program.

image11.png

Project Link

Watch what happens: does the buzzer sound when armed? Is it quiet when disarmed?

 

Challenge: Night Watch — add a fill light

Have students upgrade the program so the system can keep watching at night.

 

Activity 3

Add the light-level check: when armed and the light level is below the threshold, turn the LED light strip on; otherwise, turn it off.

image12.png

Project Link
 

See More: PIR Sensor vs AI Motion Detection

 

Key Question

How does a PIR sensor find movement, and how is it different from the AI camera?

 

There is another common way to detect movement — the PIR sensor. PIR means “Passive Infrared”. You can find it in automatic lights and simple alarms.

Let’s compare the two sensors:

 PIR sensorAI motion detection
What it sensesHeat (infrared) from warm, moving bodiesChanges in the picture (pixels)
Needs light?No — works in the darkYes — needs light (or a fill light)
What it can detectWarm moving bodies (people, animals)Anything that moves
Can it tell what it is?NoNo — only that something moved
Easily fooled byHeat sources; very slow movementLight changes, shadows, wind, noise
Common usesAutomatic lights, simple alarmsSecurity cameras, people counting, wildlife cameras

Both can only say “something is moving”. Neither knows what it is. Many real systems use a PIR sensor and a camera together, so they catch more and make fewer mistakes.

icon Lesson 5.zip 1.73MB Download(0)
License
All Rights
Reserved
licensBg
0