Micro:bit piano board Extended_course 3.2 Light_music
In this lesson, we mainly learn how to use music touch return, play music and RGB blocks of Yahboom piano expansion package.
By programming, we will realize play different songs by the two buttons of the micro:bit board, and accompanied by different twilight displays.
Mode 1 online programming: First, we need to connect the micro:bit to the computer by USB cable. The computer will pop up a USB flash drive and click on the URL in the USB flash drive: http://microbit.org/ to enter the programming interface. Add the Yahboom package https://github.com/lzty634158/YB_Piano to program.
Mode 2 offline programming: We need to open the offline programming software. After the installation is complete, enter the programming interface, click【New Project】, add Yahboom package:
https://github.com/lzty634158/YB_Piano, you can program.
3.Looking for blocks
The following is the location of the building blocks required for this programming.
4.Combine building block
The summary program is shown below:
5. Experimental phenomena
After the program is successfully downloaded, the micro:bit dot matrix will flash the note pattern, and the 3 RGB lights will flash randomly to illuminate different colors.
When the A button on the micro:bit board is pressed, the music "birthday" is played;
When the B button on the micro:bit board is pressed, the music "wedding" is played;
When the AB button on the micro:bit board is pressed at the same time, the music "ode" is played, as shown in the following figure.
PS: When the battery is used for a long time, the piano board is not powered enough. At this time, the function will not be realized normally. You can replace the new battery or use USB data cable for power supply. The USB data cable power supply mode is shown in the figure below.
The code of the experiment: 2.Light_music.rar