micro:bits come in two versions - v1 micro:bits are in the robots, and v2 micro:bits are attached to your computer.
Only v2 micro:bits have a built-in speaker, so this code will only work on your HQ micro:bits, not the ones in the moon buggies.
At the top of your code, you will see the line import radio .
Make a new line after this one, and add the following line:
import audio
Without this line, the micro:bit won't know how to play the effects listed below.
Now decide when you want the sound effect to play,
Once you have decided, type this line in the correct place:
audio.play(Sound.HELLO)
Once you have tested it, change the sound to one of these other options.
Back at the top of your code, add another line under the other imports:
import music
Where do you want the music to play? The tunes are longer than the sound effects.
Once you have decided, type this line in the correct place:
music.play(music.ODE)
Once you have tested it, change the tune to one of these other options.
If you add a tune into a function, no radio message will be sent until the music has stopped!
You can change this by telling it not to wait:
music.play(music.ODE, wait=False)
If unexpected things happen, check the order you are asking the micro:bit to do your commands in.