DFROBOT Motion Sensor Alarm User Guide

DFROBOT-LOGO

DFROBOT Motion Sensor Alarm

DFROBOT-Motion-Sensor-Alarm-PRODUCT

Specifications

  • Hardware connections (Challenge 8-1): PIR sensor to pin P0, LED Strip to pin P1
  • Variable types: Use numeric variables only in this lesson
  • PIR behavior (for counting logic): PIR outputs HIGH for 2 to 3 seconds
  • Mode options (Challenge 8-2): mode = 1 Disarmed, mode = 2 Home, mode = 3 Armed
  • Expected mode actions: Home mode activates the camera view for 5 seconds when people pass by the door; Armed mode flashes warning lights (LED)

Quick Guide

  1. Open the Coding page in Mind+ and connect hardware: PIR → P0, LED Strip → P1.
  2. Challenge 8-1 (counting): Create a numeric variable named count, set it to 0, then add a block to change count by 1 when the PIR detects motion. Show the count on the screen.
  3. Run the program; if the count jumps rapidly, add a wait 1 sec inside the loop to slow counting.
  4. Set Button A to reset: when pressed, set count back to 0.
  5. Challenge 8-2 (mode switching): Load program 8-2 and create a numeric variable named mode. Start with mode = 1.
  6. In a forever loop, add conditional logic so each mode performs its action: mode=1 do nothing; mode=2 shows doorway monitoring; mode=3 flashes warning lights.
  7. Use Button A and Button B to change mode (decrease/increase) during operation.

INTRODUCTION

Students will program with a PIR sensor to create a security alarm system that uses variables to store and modify data.

  • can create variables and store numbers inside them.
  • can adjust variable values to create a counting function.
  • can use variables as mode switches to control program behavior.

Engage

5 min.
If someone walks by your door several times, could thesystemtell the difference between passing by and lingering?

DFROBOT-Motion-Sensor-Alarm-FIG (1)

Introduce the core idea: use variables to record doorway activity and switch security modes.

Background

5 min.

What is a variable?
A variable is like a named box that can store a number or text. In Mind+, we can create variables by clicking the Make a Numeric Variable button (only use the numeric variable in this lesson).DFROBOT-Motion-Sensor-Alarm-FIG (2)

The set variable to 0 block assigns a new value to a variable.DFROBOT-Motion-Sensor-Alarm-FIG (3)The change variable by 1 block increases the value in the variable by the amount you want.DFROBOT-Motion-Sensor-Alarm-FIG (4)DFROBOT-Motion-Sensor-Alarm-FIG (5)

Build and Connect

5 min.

DFROBOT-Motion-Sensor-Alarm-FIG (6)

No extra structures arerequired;students only needahousingblock to install hardware

After groups finish installation, prompt discussion:
Where should you place the PIR sensor to best detect doorway activity?
Prompt students to install the PIR sensor depending on the discussion.

Program

25 min.

Challenge 8-1: Entrance Monitoring System

  1. Groups should opentheCodingpage in Mind+, connect theirhardware (PIR sensor topinP0,LED Strip to P1).DFROBOT-Motion-Sensor-Alarm-FIG (7)
  2. Guide them to create a variable called count and set it to0. Explain that this variable is for tracking each PIR detection.DFROBOT-Motion-Sensor-Alarm-FIG (8)
  3. Ask students to use a change variable by 1 block to count how many times the PIR detects motion. Challenge students to show the count on the screen so they can watch it climb in real time.DFROBOT-Motion-Sensor-Alarm-FIG (9)
  4. Ask students to run the program and let them observe. Guide themto addawait 1secblock inside the looptoslowDFROBOT-Motion-Sensor-Alarm-FIG (10)

DFROBOT-Motion-Sensor-Alarm-FIG (11) DFROBOT-Motion-Sensor-Alarm-FIG (12)CDFROBOT-Motion-Sensor-Alarm-FIG (13)

Extra Practice

5 min.
Ask students to improve the counter in Challenge

Make sure the count never goes below 1 or above 3.DFROBOT-Motion-Sensor-Alarm-FIG (14)Ask students to combine the counter built in Challenge8-1withthe mode switch from Challenge 8-2, then add soundeffects.DFROBOT-Motion-Sensor-Alarm-FIG (15)

NOTE: Two variables can work together—count tracks events, mode decides when to act.

Troubleshooting

  • The count jumps rapidly instead of increasing once per pass: The PIR sensor outputs HIGH for 2 to 3 seconds, so the program can increment multiple times during that period. Add a wait 1 sec block inside the loop to slow counting.
  • Mode values go out of the intended range: Ensure mode stays within valid bounds (the lesson practice suggests preventing mode from going below 1 or above 3).
  • The system doesn’t appear to respond in a specific mode: Confirm your conditional checks match the lesson logic: mode = 1 (disarmed) → no action, mode = 2 (home) → doorway monitoring for 5 seconds, mode = 3 (armed) → LED warning/flash.

Documents / Resources

PDF thumbnailMotion Sensor Alarm
User Guide · Motion Sensor Alarm, Sensor Alarm

References

Ask a Question

Use this section to ask about setup, compatibility, troubleshooting, or anything missing from this manual.

Ask a Question

Ask about setup, compatibility, troubleshooting, or anything missing from this manual. Name and email are optional.