Skip to main content

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

  1. Understand the human infrared sensor.

  2. Understand the light ring.

  3. Understand the counting loop building block.


Required materials

ItemPictureQuantity
micro:bit V21
Jacdac expansion board1
Jacdac 10cm connection line2
Human infrared sensors1
Light Ring1
USB Cable1

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

Microsoft Makecode


Makecode programming

Step 1: How to add Jacdac extension

  1. Enter Microsoft Makecode and click "New Project".

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


  1. Click "Extend" in the code drawer.

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


Step 2:

  1. 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.

  1. 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.

  1. 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

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?