Case 4 - Play Music

Part 1 Objective

User writes the program and uploads the program to mBot. User will give mBot the ability to play music, and by adjusting the corresponding musical notes and beats, any song can be played.

6e37d543-af99-4cfa-9a64-124722186d04.gif

 

Part 2 Preparation

  • mBot x1
  • USB cable x1
  • Computer with network access
  1. Use a data cable to connect the mBot to the computer

3b6ed37d-7c83-4e4c-8ff2-458feb7c6c21.gif

  1. Open MBlock5 (PC, Web, APP), click "Add" in the lower left device area, select mBot in the device library, and click “Connect”.(Live mode: you can click the building block to observe the real-time running effect, but you need to keep the data cable connected to the computer; Upload mode: You can upload the program to mBot, at which time you can unplug the data cable to run the program. ), this course needs to switch to "Upload mode".

ac1498be-f27a-4064-9b49-2ab5eb8610d4.gif

 

Part 3 Programming

When the user presses the on-board button, the song from "Brother John" is played.

2831c5c7-958c-4ff1-b3d5-284553476273.gif

Source program diagram

ea4917f4-797b-49c3-bc5f-a124d0556bb8.png

 

Part 4 Procedure source code

Lesson 4_Play Music.mblock

 

Part 5 Practice

  1. Change the type of musical note
  1. Change the musical meter
  1. Increase/decrease the number of Play Notes blocks

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.