Case 3 - Press to play

Part 1 Objective

User writes the program and uploads the program to mBot, which will activate the key recognition function, so that it can determine whether to press the key and play the note after pressing the key.



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

After the user uploads the program to the mBot, the mBot will play the corresponding musical note whenever the User presses the black button on the board.


Source program diagram



Part 4 Procedure source code

Lesson 3_Playing notes by key.mblock


Part 5 Practice

  1. Change the type of musical note
  1. Change the musical meter


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



Please sign in to leave a comment.