Example Code for micro:bit-Fire Alarm
Last revision 2026/01/14
This article provides a comprehensive guide to setting up a fire alarm using micro:bit V2, including hardware and software preparation, wiring diagrams, and safety precautions, with a focus on utilizing the MBT0042 expansion board and MakeCode platform for programming.
Hardware Preparation
- micro:bit V2
- MBT0042 expansion board
- lighter
Software Preparation
- Enter the MakeCode programming platform in browser: https://makecode.microbit.org/
- Create a new project and name it.
- Load in the program library of xia_mi board: click “setting”, and “expansion” in turn, then paste this link in the search box: https://github.com/DFRobot/pxt-DFRobot_xia_mi_Board.
Other Preparation Work
Please pay attention to the safety of using fire.
Sample Code
MakeCode Program Link: https://makecode.microbit.org/_HAJPpYYfW6hq

Result

Was this article helpful?
