What You Need:
Halloween Music on MI:Sound Speaker Board for microbit:
We gained inspiration for this tune from Michael Myers - Halloween Theme Song - Piano Tutorial published by Thrive Basics, which you can watch here.How to Code the MI:Sound:
- Go to the 'Input' section and drag and drop the 'on shake' function.
- The 'Basic' section has a 'show LEDs' function. Drag and drop it into the 'on shake' function. There are example images after the coding section.
- In the 'Loops' section, and drag and drop 'repeat X times, do' and put this underneath the 'show LEDs' function. Change the number 'X' to 5.
- Go to the 'Music' section and drag and drop 'play tone X for X beat' into the 'do' section of 'repeat 5 times'. Then, place the same function into the 'do' box until you have 7.
- Click 'Middle C' and use the keyboard to select the following tones in this order. High C#, Middle F#, Middle F#, High C#, Middle F#, High D and Middle F# which are all for 1/2 a beat.
- Then, go to the 'Loops' section and drag and drop 'repeat X times, do'. Put this underneath the completed 'repeat 5 times' section. Change the number 'X' to 2.
- Go back to the 'Music' section. Then, drag and drop another 7 'play tone X for X beat' into the 'repeat 2 times' section.
- In accordance with this, use the keyboard to select the following in this order. High C, Middle F, Middle F, High C, Middle F, High C and Middle F which are all for 1/2 a beat.
- There are two differences between the first two sections of code. Firstly, the first section has '#' on some of the notes. Secondly, the last 3 notes are different as the first section has 'Middle F#, High D, Middle F#' as the last three notes (call this pattern 1). Also, the second section having 'Middle F, High C, Middle F' (call this pattern 2).
- Repeat these sections until there is 5 completed section, in the following order according to the pattern number: 1, 2, 1, 2, 1 with the 'repeat X times' being 2.
- When this is done, you can then test it. Either by pressing the 'on shake' button on the online micro:bit or by downloading the code to the micro:bit up.
Example Images for BBC micro:bit Screen
The BBC micro:bit has a 5x5 display screen, which means you can create a symbol to complete your Halloween project! Check out some of the examples that we produced, including ghosts, a cross or a creepy smile!The Completed MI:Sound Code:
For those that want to get the MI:Sound playing music immediately, the code can be downloaded from the editor below.©Kitronik Ltd – You may print this page & link to it, but must not copy the page or part thereof without Kitronik's prior written consent.