Micro:bit piano board Extended_course 3.4 Touch_play_song
In this lesson we mainly learn how to use the music touch return, music button, play music and RGB blocks of Yahboom piano expansion package.
By programming, touch the L, M, H keys on the piano extension board to play different custom songs.
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.
How to create a new variable：
4.Combine building block
See the hex file for the summary procedure.
5. Experimental phenomena
After the program is successfully downloaded, the micro:bit piano is powered on normally.
When the H button is touched, the 3 RGB lights light up in red, and the LED dot matrix scrolls back to display “painter”, then the buzzer will play the song “Painter” with different lights flashing.
When the M button is touched, the 3 RGB lights light up in green, and the LED dot matrix scrolls back to display “school song”, then the buzzer will play the song “School Songs” with different lights flashing.
When the H button is touched, the 3 RGB lights light up in yellow, and the LED dot matrix scrolls back and displays "two tigers", then the buzzer will play the song "Two Tigers" with different lights flashing.
About the pitch of these three songs:
A comparison table of numbers and pitch blocks in the notation:
After testing, I think that the best results are obtained on several blocks.
About the beat of this song:
If the number is underlined, we set its beat to 1/2. If there is a bar behind the number, we set its beat to 2, and if it is just a single number, the beat is 1.
There is a small black dot on the number, which means that the tone needs a higher tone, and we choose a higher tone.
There is a small black dot below the number, indicating that the tone needs to be lower, and we choose a lower pitch.
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: 4.Touch_play_song.rar
- Micro:bit piano board Tutorial
- Last Tutorial>> Micro:bit piano board Extended_course 3.3 Pianist_under_the_light
- Next Tutorial>> Micro:bit piano board Extended_course 3.5 Music_playing_spectrum