5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10

Micro Python Basic Course 7: Play built-in music

Posted by SuFiona on

Learning goals:

This lesson learns to play built-in music by Python programming. For example: heart.


from microbit import *

import music


We need to import the music library function, and call the built-in music. WEDDING melody from the library, the following is a complete list of melody:


• music.PRELUDE
• music.ODE
• music.NYAN
• music.RINGTONE
• music.FUNK
• music.BLUES
• music.BIRTHDAY
• music.WEDDING
• music.FUNERAL
• music.PYTHON
• music.BADDY
• music.CHASE
• music.BA_DING
• music.JUMP_UP
• music.JUMP_DOWN
• music.POWER_UP
• music.POWER_DOWN

Programming and downloading

1.You should open the Mu software, and enter the code in the edit window, , as shown in Figure 7-1.

Note! All English and symbols should be entered in English, and the last line must be a space.


Figure 7-1

2.As shown in Figure 7-2, you need to click the Check button to check if our code has an error. If a line appears with a cursor or an underscore, the program indicating this line is wrong.


Figure 7-2

3.You need to connect the micro data cable to micro:bit and the computer, then click the Flash button to download the program to micro:bit as shown in Figure 2-3.

image.png Figure 7-3

4. After the download is successful, we need to connect P0,GND of micro:bit to head phone by crocodile clip. Then, you can hear that buzzer play ODE .


The code of the experiment: 7.Play built-in music.zip

Micro Python Basic Course


Leave a comment

Please note, comments must be approved before they are published