Welcome to Building:bit Superkit repository
1.Buzzer play music
Buzzer play music
Buzzer play music1. Learning objectives2. Code analysis3. Write and download programs4. Experimental phenomenon
1. Learning objectives
In this course, we mainly learn how to drive the buzzer on the superbit expansion board through Python programming.
The buzzer is located on the expansion board as shown in the figure below.

! Notes:
Before conducting this experiment, we need to connect the jumper cap to the P0 and Buzzer pins on the Super:bit expansion board, as shown in the figure below.

2. Code analysis
The program for this course is as follows
xfrom microbit import *import musicdisplay.show(Image.MUSIC_QUAVER)music.play(music.BIRTHDAY)First, import the library needed for this lesson from microbit: the music library is dedicated to playing music;
display.show(Image.MUSIC_QUAVER): Display the musical note pattern on the microbit dot matrix;
music.play(music.BIRTHDAY): Play the birthday song.
For more music, you can refer to the music section of the official API function of micro:bit.
Website: https://microbit-micropython.readthedocs.io/en/latest/
3. Write and download programs
- Open the Mu software and enter the code in the editing window. Note! All English and symbols should be entered in English, use the Tab key for indentation, and the last line ends with a blank program.
- Click the thumb 'Check' button to check if there are any errors in our code. If a cursor or underline appears in a line, it means a syntax error. Please check and modify it. If there is no error, the lower left corner will prompt that there is no problem with the detection.

- Click the 'REPL' button to check whether the Superbit library has been downloaded. If not, please refer to [Preparation before class] --> [2.4 Python Programming Guide].

- After the program is written, connect the computer and microbit mainboard with a microUSB data cable, click the 'Flash' button to download the program to the micro:bit mainboard. (You need to click the 'REPL' button again to turn off the import library file function before you can download the program normally).

- If the download fails, please confirm whether the microbit is connected to the computer normally via the microUSB data cable and the Superbit Python library has been imported.
4. Experimental phenomenon
After the program is downloaded successfully, the micro:bit dot matrix will display the musical note pattern and the buzzer will play "Birthday Song" once.