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.



Part 2 Preparation

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


  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".



Part 3 Programming

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


Source program diagram



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



Please sign in to leave a comment.