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



Microbit-Python Course 6.8 Sing a song

Posted by Fiona Su on

Microbit-Python Course 6.8 Sing a song

Learning goals:

In this lesson, you can use the micro:bit robot to play music, the robot sings a ODE song, and the dot matrix displays a buzzer pattern.

Code

from microbit import *
import music
display.show(Image.MUSIC_QUAVER)
music.play(music. WEDDING)

Below is a complete list of melody:

• music.DADADADUM
• music.ENTERTAINER 

• music.PRELUDE
• music.ODE
• music.NYAN
• music.RINGTONE
• music.FUNK
• music.BLUES
• music.BIRTHDAY
• music.WEDDING
• music.FUNERAL
• music.PUNCHLINE
• music.PYTHON
• music.BADDY
• music.CHASE
• music.BA_DING
• music.WAWAWAWAA
• 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 8-1.

Note! All English and symbols should be entered in English.

image.png

 Figure 8-1

2.As shown in Figure 8-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.

image.png

 Figure 8-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 8-3.

image.png Figure 8-3

4.After downloading the program, you can see that Micro:bit will display music pattern and buzzer will play《ODE》, as shown in Figure 8-4.

image.png

Figure 8-4

!!!Note: Before downloading the program, you need to set the buzzer switch S3 to the FM , otherwise there is no sound.

The code of the experiment: 8.Sing a song.rar

Buy Yahboom Croco:kit sensor starter kit for micro:bit

Tutorial

0 comments

Leave a comment

Please note, comments must be approved before they are published