Lesson at a glance
maze.education/microbit/lessons/music-maker
- Grades
- Grades 4 to 7
- Time
- 45 to 60 minutesThe CAPS gives Coding and Robotics 2 hours a week (Coding and Robotics CAPS, Grades 4 to 6, page 22; Grades 7 to 9, page 22).
- Level
- Some experienceFor classes that have used the micro:bit and MakeCode once or twice.
- Board
- Any micro:bit
- Code with
- MakeCode and Purple Mash blocks, with Python as an extension
- CAPS
- Creative Arts, Coding and RoboticsFits: Grade 5, Term 3 · Where it fits
Learning intentions
Learners will learn to:
- Program buttons and a gesture to play notes and melodies.
- Compose a short melody of eight notes and play it back.
- Explain how pitch relates to frequency: the higher the number, the higher the note.
Success criteria
Each learner can say:
- I can make buttons A and B, both buttons together and a shake each play a note or a tune.
- I can compose an eight-note melody in the melody editor and play it back.
- I can explain why 392 Hz sounds higher than 262 Hz.
- I can explain the difference between playing a sound until done and in background.
Competencies
From the Coding and Robotics CAPS places this lesson cites.
- R.7Create, test and execute a set of robotic instructions
Key words
- pitch
- How high or low a note sounds.
- frequency
- How many times a second a sound vibrates, measured in hertz (Hz).
- beat
- The steady pulse of music. Notes last a whole beat, half a beat and so on.
- tempo
- How fast the music goes, in beats per minute (bpm).
- melody
- Notes played one after another to make a tune.
- IPO table
- A plan with three columns: the input, the processing and the output.
What you need
- One micro:bit per learner or pair, with a USB cable and a battery holder
- A micro:bit V2 for the sound: it has a speaker built in, and a micro:bit V1 does not
- A computer with Chrome or Edge for each learner or pair
From our shop: BBC micro:bit V2 Go, BBC micro:bit V2.21 Next Gen Classroom Pack
Safety
- Keep the volume low and the micro:bit away from ears. Someone may be sensitive to sudden sounds, so warn the class before the first sound plays.
- Use the battery holder with two AAA batteries. Never mix old and new batteries, and take the batteries out before the kits are packed away.
The lesson plan
One lesson of 45 to 60 minutes in three parts: introduction, lesson development and consolidation. The CAPS gives Coding and Robotics 2 hours a week, so it fits one of the week's lessons. Times are a guide.
Introduction
5 to 10 minutesRetrieval practiceWhat is an event in a program? (Something that happens, such as a button press or a shake, that starts part of the program.)
Problem statementFor the Heritage Day concert, the music teacher has one keyboard for a class of forty, so most learners wait a long time to try out a melody. Program a pocket instrument on the micro:bit V2 that plays notes, a scale and a tune, and compose an eight-note melody for it.
- Sing or play a scale: do, re, mi, fa, so, la, ti, do. Learners show high and low notes with their hands. Tell them that every note is a number to a computer: middle C vibrates about 262 times a second, so its frequency is 262 Hz.
- Read the problem statement together. Ask: what should the instrument play, and which button should do what?
Lesson development
35 to 40 minutes- Unplugged first. Fill glasses or bottles with different amounts of water and tap them gently with a pencil. Which one makes the highest note? Learners arrange them from low to high and play a short tune.
- Plan on paper first. Pairs fill in an IPO table for the instrument, with a row for each input: button A, button B, A and B together, and a shake. Under the table they write their own eight-note melody as note letters, such as E D C D E E E E.
- Predict. Ask: which button will play the higher note, A at 262 Hz or B at 392 Hz? What will change when the tempo goes from 120 to 60, and what will stay the same? Pairs write their answers beside the plan.
- Build in blocks. Pairs share one computer, with the simulator's sound on low. The driver builds buttons A and B from the steps on the Blocks tab; the navigator checks each event against its row of the IPO table. Swap roles halfway, after button B, so the new driver builds A and B together and the shake.
- Test and debug. Test each row of the IPO table in the simulator, then download the program to a micro:bit V2. Did B sound higher, as you predicted? Change the tempo from 120 to 60, then to 200, and compare with your prediction. If there is no sound, check the board has the gold logo of a V2.
- In on button A+B pressed, click the melody to open the melody editor and put in the eight-note melody from your plan. Pairs perform it for another pair and explain how they built it.
Plan on paper: a model answer
In pairs, fill in an IPO table with a row for each input the instrument uses, then write your own eight-note melody as note letters.
IPO table
Input Processing Output Button A is pressed Start middle C (262 Hz) for half a beat, in the background C plays, and the letter C shows while it plays Button B is pressed Start G (392 Hz) for half a beat, in the background G plays, and the letter G shows while it plays A and B are pressed together Show the eighth note, then play the eight notes from C up to the next C at 120 beats a minute, until done The eighth note picture, and the scale The board is shaken Start the Entertainer melody, in the background The tune plays Consolidation
5 to 10 minutes- Ask: what is the difference between pitch and tempo? Play two tones, 262 and 392. Which number is the higher note?
- Ask: why do we start the note in the background before showing the letter? (So the letter shows while the note plays, not after it.)
- Back to the problem: could a class share these instruments to try out melodies for the concert, and what would you add to make it more useful? Learners check themselves against the success criteria.
Build it, step by step
Pairs build the program in blocks, following the numbered steps, with the same program as text beside them to check against or paste. Test in the simulator before sending it to a board.
These are the MakeCode steps. The other routes are on the lesson's web page.
Build it in MakeCode blocks
- Start a New Project called Music maker.
- From Input, drag in on button A pressed.
- From Music, drag the play tone block (Middle C for 1 beat) into it. Change 1 beat to 1/2 beat, and until done to in background.
- From Basic, add show string under it and type C.
- Do the same for button B: click the note, pick G on the keyboard (392 Hz) and show the letter G.
- Add on button A+B pressed (change the letter in a button block to A+B). Put show icon with the music note in it, then play melody ... at tempo 120 (bpm) until done from Music.
- From Input, drag in on shake, and from Music add play melody entertainer in background.
- Test in the simulator, then Download.
input.onButtonPressed(Button.A, function () {
music.play(music.tonePlayable(262, music.beat(BeatFraction.Half)), music.PlaybackMode.InBackground)
basic.showString("C")
})
input.onButtonPressed(Button.AB, function () {
basic.showIcon(IconNames.EighthNote)
music.play(music.stringPlayable("C D E F G A B C5 ", 120), music.PlaybackMode.UntilDone)
})
input.onButtonPressed(Button.B, function () {
music.play(music.tonePlayable(392, music.beat(BeatFraction.Half)), music.PlaybackMode.InBackground)
basic.showString("G")
})
input.onGesture(Gesture.Shake, function () {
music.play(music.builtInPlayableMelody(Melodies.Entertainer), music.PlaybackMode.InBackground)
})To use the text instead: open MakeCode, start a new project, click JavaScript at the top, replace what is there with this code, then click Blocks to see it as blocks.
To send it to the board, click Download. In Chrome or Edge, MakeCode can connect to the micro:bit by USB so the program goes straight onto it. Otherwise a .hex file downloads: drag it onto the MICROBIT drive.
Purple Mash follows the UK school years, which run about one grade ahead of ours: Year 3 is roughly Grade 2 here, Year 4 roughly Grade 3 and Year 5 roughly Grade 4. 2Simple says its micro:bit lessons can be adapted for other ages, so older learners who are new to the micro:bit can use them too.
These steps are our own. 2Simple's lesson has its own plan, slides and videos, which teachers with a Purple Mash login can use alongside this one.
Our steps in Free Code micro:bit
Block names in Free Code micro:bit are not the same as MakeCode's, so these steps say what each block does. Check the exact names in Purple Mash.
- Log in to Purple Mash and open the lesson from the Computing Scheme of Work, or the micro:bit projects in the Computing area. They use Free Code micro:bit, 2Simple's block coding tool for the micro:bit (2Simple's help pages also call it 2Code micro:bit).
- Open Free Code micro:bit from the Sounds and Gestures lesson or the Jukebox project.
- Add a button A block that plays one note, and a button B block that plays a different note.
- Add a gesture block, such as shake, that plays a tune.
- Check in Purple Mash which notes and tunes the sound blocks offer, then compose your own.
- Test the program on the on-screen micro:bit (2Simple calls it the micro:bit emulator) before you send it to a board.
- Save your work, open the purple menu at the top and choose Download.Hex. Plug in the micro:bit with a USB cable that carries data and drag the .hex file onto the MICROBIT drive. On an iPad, open the file in the micro:bit app and tap Send to micro:bit.
2Simple says the micro:bit projects can also be coded in Python in Pieces, if your school has it.
Extension: text-based coding, beyond the CAPS
The same program in MicroPython, for the micro:bit Python Editor. It suits Grade 7 to 9 learners who are ready for text-based code. The CAPS itself follows a block-based approach (Coding and Robotics CAPS, Grades 7 to 9, page 24).
# Music maker: A plays C, B plays G, A and B together play a scale, shake plays a tune.
from microbit import *
import music
scale = ["C4:4", "D4:4", "E4:4", "F4:4", "G4:4", "A4:4", "B4:4", "C5:4"]
while True:
if button_a.is_pressed() and button_b.is_pressed():
display.show(Image.MUSIC_QUAVER)
music.play(scale)
button_a.was_pressed()
button_b.was_pressed()
elif button_a.was_pressed():
music.play("C4:2", wait=False)
display.show("C")
elif button_b.was_pressed():
music.play("G4:2", wait=False)
display.show("G")
elif accelerometer.was_gesture("shake"):
music.play(music.ENTERTAINER, wait=False)
sleep(50)In MicroPython a note is written as letter, octave and length, so C4:4 is middle C for four ticks (one beat). The two was_pressed lines after the scale clear the presses, so A and B do not play their own notes afterwards.
Open the Python editor, replace the code that is there with this program (or open the downloaded file), then click Send to micro:bit. MakeCode also has a Python view, which is written a little differently.
Extension or homework
Challenges for learners who finish early, or to take further in a club or as homework.
- Challenge 1
Keep your tune in time with the Metronome and beat maker on a second board.
- Challenge 2
Turn the micro:bit into a theremin: play a tone whose pitch rises as you tilt the board, using acceleration (mg) x.
- Challenge 3
Record the notes of a song the class knows as letters on paper, then play it back on the micro:bit.
- Challenge 4
Program the school song Bana ba Sekolo, the song the Grade 5 CAPS uses, so that it plays when A is pressed.
Support and extension
Support
For learners who need more help
- Build button A only, then copy and change it for button B.
- Give learners a card with note names and frequencies: C 262, D 294, E 330, F 349, G 392.
Extension
For learners who are ready for more
- Use on logo pressed (micro:bit V2) for a third note, and make a three-note riff.
- Write the melody for a song the class knows, such as a school song or Happy Birthday, in the melody editor.
Informal assessment
Ask these as learners work. Informal assessment happens every day and is not recorded.
- Which is higher, a tone of 262 Hz or one of 392 Hz?
- What does the tempo number change?
- What is the difference between until done and in background?
E is 330 Hz. Is it higher or lower than C, and how do you know?
Observation checklist
Watch pairs as they plan, build and test. Write each pair's initials under the level you see.
| Watch for | Beginning | Developing | Accomplished | Exemplary |
|---|---|---|---|---|
| Fills in the IPO table with a row for each input before building. | ||||
| Builds each event and tests it against its row of the table. | ||||
| Predicts which note is higher and what the tempo changes, then checks by listening. | ||||
| Composes an eight-note melody and plays it back. | ||||
| Explains that a higher frequency gives a higher note. |
- Beginning:
- not yet, even with help
- Developing:
- with help
- Accomplished:
- on their own
- Exemplary:
- on their own, and explains it or takes it further
The four levels are the CAPS rubric levels (Coding and Robotics CAPS, Grades 4 to 6, page 176; Grades 7 to 9, page 163). The short descriptions are ours.
This lesson is not a formal task, but it is good practice for the term's practical task in Grades 4 to 6 (Coding and Robotics CAPS, Grades 4 to 6, page 170), and for the mini-PATs in Grades 7 to 9 (Coding and Robotics CAPS, Grades 7 to 9, page 157).
Common mistakes and fixes
- There is no sound on our micro:bit.A micro:bit V1 has no speaker, so use a micro:bit V2 (it has a gold logo on the front). On a V2, check the volume has not been set to 0.
- Pressing A and B together plays the single notes.Press both buttons at exactly the same time, and check there is an on button A+B pressed block.
- The tune keeps playing over the notes.That is in background at work. Change the shake melody to until done if you want it to finish first.
Where it sits in CAPS
- Coding and RoboticsFitsGrade 5, Term 3: a button that plays music on the micro:bit.Source: Coding and Robotics CAPS, Grades 4 to 6, Grade 5, Term 3, Robotics, R.7 Create, test and execute a set of robotic instructions, page 115:
The music for the song must play when Button A is pressed.
- Coding and RoboticsFitsGrade 5, Term 3: code a song for the micro:bit to play (the CAPS uses Bana ba Sekolo).Source: Coding and Robotics CAPS, Grades 4 to 6, Grade 5, Term 3, Robotics, R.7 Create, test and execute a set of robotic instructions, page 115:
write the code to produce music for the song, Bana ba Sekolo,
- Creative ArtsGrade 6 Creative Arts: making short musical phrases with pitch and rhythm.Source: CAPS Life Skills, Grades 4 to 6, Grade 6, Creative Arts (Performing Arts), Topic 2: Improvise and create:
Musical phrases exploring dynamics, pitch and rhythmic patterns
- Creative ArtsFits Creative Arts (Music) in Grade 7: composing and performing short melodies.
Coding and Robotics quotes come from the Department of Basic Education's final CAPS, with the page number of the 2024 printed edition (the Department's October 2025 library copies number their pages differently). Schools may teach a topic in another term: the CAPS leaves the order to each school's annual teaching plan.
micro:bit is a trade mark of the Micro:bit Educational Foundation, and BBC is a trade mark of the British Broadcasting Corporation. Maze Education is an independent reseller of genuine BBC micro:bit products. Our teacher training and our other products and services are our own, and are not endorsed by the Foundation or the BBC.

