Example Code for micro:bit-Button LED
Last revision 2025/12/31
This article provides a comprehensive guide on connecting a button and an LED to a micro:bit using pins P0 and P1. It includes user library links for MakeCode and Mind+, a detailed wiring diagram, and sample code to facilitate learning and implementation.
Hardware Preparation
Connect the button module to pin P0 and the LED module to pin P1.
Software Preparation
-
MakeCode User Library Link: click here
-
Mind+ Upload Mode User Library Link: click here
-
Mind+ Python Mode User Library Link: click here
Wiring Diagram

Sample Code
| MakeCode Program ScreenshotProgram Link:click here | Mind+ Program Screenshot |
![]() |
![]() |
Result

Was this article helpful?


