22. Case 18: Music Box

22.1. Introduction

This is a music box. We can control the buzzer on the micro:bit to emit different melody by pressing the button A on the micro:bit.

22.2. Quick to Start

Materials

Nezha expansion board × 1

micro:bit × 1

Tips: You may need to purchase Nezha Inventor’s Kit if you want all the above compoents.

Connection Diagram

Insert the micro:bit to Nezha expansion board.

../../_images/case_18_03.png

22.3. MakeCode Programming

Programme as the picture shows:

../../_images/case_18_15.png

Result

Press button A to switch the music.

microbitKit/Nezha_Inventor_s_kit_for_microbit/./images/case-gif-18.gif