Case 6: Human motion detection alarm
Introduction
When the human infrared detection sensor detects a person moving, the light ring will light up and an alarm will sound.
Case purpose
Understand the human infrared sensor.
Understand the light ring.
Understand the counting loop building block.
Required materials
| Item | Picture | Quantity |
|---|---|---|
| micro:bit V2 | ![]() | 1 |
| Jacdac expansion board | ![]() | 1 |
| Jacdac 10cm connection line | ![]() | 2 |
| Human infrared sensors | ![]() | 1 |
| Light Ring | ![]() | 1 |
| USB Cable | ![]() | 1 |
Sensor principle description:

Principle description:
Human body red sensor: a sensor that senses human movement.

Principle description:
Light ring: a circular light ring composed of 8 RGB lights.
Connection diagram
As shown in the figure below, insert the micro:bit into the Jacdac expansion board, and use the connecting wire to connect the human infrared sensor and the light ring to the gold finger interface of the Jacdac expansion board in a star shape.

Programming software
Makecode programming
Step 1: How to add Jacdac extension
- Enter Microsoft Makecode and click "New Project".

- In the pop-up window, enter a project name and click Create.

- Click "Extend" in the code drawer.

- In the pop-up interface, enter "Jacdac" and click the search icon, select the Jacdac software library, as shown in the figure.

Step 2:
Connect micro:bit to the computer with a data cable.
Note: If the micro:bit is running the Jacdac program for the first time, please pre-install a blank Jacdac program on the motherboard, otherwise skip this step.

- Connect the sensor, MakeCode will automatically identify and simulate it, and the sensor will provide real-time feedback of the sensor status in the simulation area.

Click "ADD BLOCKS" sensor expansion module.
Note: To connect a new sensor, repeat the "Click "ADD BLOCKS" sensor expansion module" operation proces

Write the program as shown

Reference program link:
https://makecode.microbit.org/S21420-49463-47317-16127
You can also download the program directly from the following webpage, and start running the program after downloading.
Result
When the human infrared detection sensor detects a person moving, the light ring will light up and an alarm will sound.

Thinking
What other aspects of life can the human infrared sensor be used in?
.png)




