Code Example for micro:bit-Tilt Alarm System

The article offers a comprehensive guide to building a micro:bit tilt alarm system, detailing necessary hardware and software, illustrating wiring diagrams, and providing sample code for programming. It describes the system's functionality of detecting tilt and activating a buzzer to alert users.

Hardware Preparation

BOS0005 Tilt Sensor BOS0020 Buzzer Module
MBT0039 Micro:bit BOS0040 Micro:bit BOSON Expansion Board

Wiring Diagram

Sample Code

Mind+ Sample Program:

Result

When it is placed horizontally, it outputs low; when it tilts, output high. When the tilt sensor detected tilt, the buzzer module will be activated and start to buzz to give an alarm.

Additional Information

Flow Chart:

Was this article helpful?

TOP