Code Example for micro:bit-Music Box

This article offers a step-by-step guide to create a music box using micro:bit and BOSON modules, including programming with Mind+ and Makecode, wiring setup, and sample codes to enhance your DIY electronics project.

Hardware Preparation

BOS0004 Light Sensor BOS0020 Buzzer Module BOS0030 Splitter Module
BOS0019 Multicolor String Light BOS0035 Mainboard-3IO MBT0039 Micro:bit

Software Preparation

Mind+ or makecode graphical programming tools.

Wiring Diagram

Other Preparation Work

Sample Code

Mind+ Sample Program:

Result

The light sensor can measure the light intensity. We take the music box to a dark place, when the sensor senses the darkness, the box lights up and the buzzer starts to sing.

Additional Information

Flow Chart:

Was this article helpful?

TOP