AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

A sound board

Week 20 · Unit 8: Be a musician · 3 lessons
3

A sports day sound board

Computing 3: Unit 8, pp. 119–134
GoalPlan, build and test a sound board that has three inputs, each with its own icon and sound.
New words
sound board · a program that plays a different sound for each inputplan · to decide what to build before you build ittest · to try each part to see if it works
Explanation

A sound board plays a different sound for each input. Our sports day sound board has three inputs: button A, button B and shake. Plan it first on paper. For each input choose an icon, a volume and a sound or melody. Then build one script at a time and test it before you go on. When everything works, make a change and predict what will happen before you run it. If you code with a partner, one can build while the other checks the plan.

InputIconVolumeSound
button Atarget120slide
button Bgiraffe80spring
shakediamond200wedding melody
Worked examples
Script Aon buttonApressedshow icontargetset volume120play soundslideuntil doneclear screenScript Bon buttonBpressedshow icongiraffeset volume80play soundspringuntil doneclear screen
Here is the code for button A and button B. Each script ends by clearing the screen.
Script shakeonshakeset volume200show icondiamondstart melodyweddingrepeatingoncepause (ms)2000clear screen
The third script starts with a shake. A melody comes from a different list from the sounds, so we use “start melody”. Start melody does not wait for the tune to end, so a pause of 2000 ms keeps the diamond on the lights before the screen is cleared. The whole program has three scripts, one for each input.
ChangePrediction
B: volume 80 to 200the spring sound is louder; A and shake do not change
A: icon target to ghosta ghost appears when A is pressed
shake: melody wedding to birthdayanother tune plays when you shake the board
Test and change. After testing, we make one change and predict the result.
Class activity

Paper sound board (in pairs): draw a micro:bit with buttons A and B on paper. Make three cards: “A: show target, slide”, “B: show giraffe, spring”, “shake: show diamond, wedding”. One of you is the micro:bit and does what the cards say when the other one does an input (taps, or shakes the paper). Swap roles. Then change one card, predict what the micro:bit will do and test it. What did you learn from working together? If you have a computer or tablet, ask a grown-up to help you build it in a simulator.

Practice
1
In the sports day sound board, how many scripts are there, and what starts each one?
2
Add a fourth input to the sound board: the logo. When the logo is pressed, it should show a ghost and play the giggle sound at volume 90. Which blocks go in the gaps?
Script logoon logopressed???
3
This script plays too loudly. What is the mistake?
on buttonBpressedshow icongiraffeplay soundspringuntil doneset volume80clear screen
4
Why is it a good idea to test each script before you build the next one?