Example Code for micro:bit-Button-controlled Lighting
This article provides a step-by-step guide to using micro:bit and Mind+ to control RGB LED strips with a push button, including hardware setup, software preparation, and sample code for creating interactive lighting projects.
Hardware Preparation
![]() |
![]() |
|---|---|
| BOS0002 Push Button Module(i2r/i2g/i2b) | M011.00184 RGB LED Strip |
![]() |
![]() |
| MBT0039 Micro:bit | BOS0040 Micro:bit BOSON Expansion Board |
Software Preparation
Before using the colorful light strip, load the library in Mind+. Open the Mind+ programming platform, find the "Extension" in the lower left corner and click it, then click the WS2812 RGB light in the "display" to load the relevant commands. At this time, the display module will appear in the command area. After completing the above steps, connect the light strip to the micro:bit board to control the effect of the light strip through programming.
Wiring Diagram

Other Preparation Work
Flow Chart:

Sample Code
Mind+ Sample Program:
Makecode Sample Program:
Was this article helpful?




