Example Code for micro:bit-Key Detection Function (Trigger Event)
Last revision 2025/12/31
The article provides a step-by-step guide on using example code to detect key touches on a micro:bit and trigger events, with instructions on hardware and software setup, including Makecode and Mind+ platforms.
Hardware Preparation
- Math & Automatic expansion board for micro:bit, Quantity: 1
- micro:bit, Quantity: 1
Software Preparation
Makecode graphical programming, Mind+ platform.
Makecode Library Address.
About how to install a software library?
Wiring Diagram
No specific wiring required (touch keys are integrated on the board).
Other Preparation Work
Install the Makecode library from https://github.com/DFRobot/pxt-Math-Automatic.
About how to install a software library?
Sample Code

Result
Show a "heart" pattern on micro:bit LED matrix when key 3 is touched.
Was this article helpful?
