Case 12: The Burglar Alarm in Shops
Contents
14. Case 12: The Burglar Alarm in Shops#
14.1. Introduction#
After installing the bulglar alarm device in shops, program to send alarms if someone breaks into the shops.
14.2. Function#
Detect the magnet from the magnetic(compass) function on the micro:bit, if the magnet goes far from the micro:bit, program to send alarms and light on the LED.
14.3. Products Link#
Note: A piece of magnet requires in this project.
14.4. Picture#
14.5. Hardware Connection#
Connect the red led to P1 port on IoT:bit.
14.6. Software Program#
Click “Advanced” in the MakeCode drawer to see more choices.
For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “iot-environment-kit” in the dialogue box to download it.
Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.
14.7. Program#
Detect the magnetic intensity in the current field, if the returned value is below the threhold, program to send alarms and flash on the led.
14.8. Result#
If someone breaks into the shop, the device sends alarms and the led keeps flashing.