Example Code for micro:bit-Touch Music

Last revision 2025/12/31

This guide offers a step-by-step approach to creating interactive touch music projects using micro:bit, a buzzer, and Makecode programming. It covers essential hardware and software preparations, wiring diagrams, and provides sample code to facilitate the creation of sound-responsive projects.

Hardware Preparation

  • Math & Automatic expansion board for micro:bit, Quantity: 1
  • micro:bit, Quantity: 1
  • Buzzer, 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

Touch Music
Touch Music Code Download

Result

Touch key 1~7, the buzzer makes different sounds; touch the rest to play different music.

Was this article helpful?

TOP