14. case 11 intruder detection system#

14.1. Our Goal#

Make a simple intruder detection system.

14.2. Materials#

1 x ELECFREAKS micro:bit Smart Home Kit A scissors A bottle of glue A piece of cardboard

14.3. Background#

The buzzer sounds using a oscillator.

What is a “intruder detection system” ?#

In this project, we are going to create an intruder detection system which will sound when someone opens the door. The status of the house will be displayed on the OLED.

Principle of a simple intruder detection#

The crasher sensor receives crash signal and send the alarm signal to the micro:bit. Then the buzzer will sound and the status of the house will be displayed on the OLED.

14.4. Practical Operation#

Prepare a scissors, a bottle of glue and a piece of cardboard. Stick the paper you prepared on the cardboard and clip it as you need.

Set up as below:

The front side:

../../_images/RL8DL2M1.png

The back side:

../../_images/K56Vqzl.jpg

14.5. Hardware Connect#

Connect the crash sensor to the P1 port of the expansion board. Plug in the OLED as shown in the picture below.

../../_images/MLFMqXq.jpg

14.6. Software#

makecode

14.7. Programming#

Step 1#

Click “Advanced” in the makecode code drawer for more codes.

../../_images/2qCyzQ73.png

We need to add a new codebase for programming of smart home. Finding “Extensions” at the bottom of code block and click it. Then a message box will show up, search “smart home”, and download this new codebase.

../../_images/OY706rv.png

Note: If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Projects file menu.

Step 2#

Snap the on start block from Basic, set the P1 port to touch detect port.

../../_images/faLxLSQ.png

Step 3#

Since there are only two conditions, we need only one “else-if”statement. When crash sensor is triggered, the buzzer will sound and the OLED will display the message “Intruder Detected”. Or else, if there is no force is applied to the crash sensor, the buzzer will not sound and the OLED will display the message “The house is safe”.

../../_images/jt4jWwZ.png

Program#

Program link:https://makecode.microbit.org/_D6v8RH0dFYk1

You also could directly download program by visiting website as below:

14.8. Result#

You have created a intruder detector!

14.9. Think#

What can you do more with the smart home kit?

14.10. Questions#

14.11. More Information#