The Anti-theft Device

The Anti-theft Device

Purpose

The anti-theft device is able to alarm with sound and lights while the objects put above the device are taken away.

Materails

micro:bit x 1

Nezha expansion board x 1

Crash sensor x 1

OLED display x 1

LED-red x 1

RJ11 wire x 3

Bricks x N

Assembly steps

Build a device as the picture shows:

Hardware Connections

Connect the crash sensor to J1 port, red LED to J2, and OLED to IIC port on Nezha expansion board.

Software programming

Go to MakeCode editor:(https://makecode.microbit.org/#editor)Click settings on the left top to choose extensions in the menu to add the package.

Search with Planet X in the dialogue box and add it to the package.

In forever brick, if the crash sensor connecting to J1 port detects the status of being pressed, set the OLED display text: “your treasure is safe”, and set the led connecting to J2 port in off status.

In forever brick, if the crash sensor connecting to J1 port detects the status of not being pressed, set the OLED display text: “your treasure not safe”, and set the led connecting to J2 port in on status and alarm.

Completed code:

Link:https://makecode.microbit.org/_7rjPTKcvpJvM

Result

The anti-theft device will alarm and flash on if the objects placed above it are taken away.