The micro:bit has no built-in microphone, but you can hear the sounds it produces by connecting it to a buzzer or by using crocodile clips to connect it to a pair of headphones.
You can code the microbit to play tunes using the red Music blocks. If you click the number in the white box after play tone the editor will show you a piano keyboard and the name of the note you’ve clicked on.
You can also change the length of the note by clicking on the dropdown list for the number of beats to hold it for. There are three versions of each letter name for a note on the keyboard: Low, Middle and High.
You can find the notes for lots of popular tunes on the web by looking for “sheet music”.
If you don’t read music, you could try https://noobnotes.net/popular/ which gives the letter names of the notes instead of the musical notation.
Each tune’s page has a picture of a piano keyboard at the top, with the note names on the keys. Instead of using the words Low, Middle and High for notes they have:
.A = Low A
A = Middle A
^A = High A
They don’t include the length of the notes, so you’ll have to work out how many beats to tell the micro:bit to play each one.
So that you can control when the microbit plays the tune, you could put the music blocks inside a pink Input block:
Or code the micro:bit to play the chorus of “Shake it off” if you shake it:
Inside the green repeat block, add the blocks to play the notes middle A for 1⁄2 a beat, middle B for 1⁄2 a beat and middle G for 2 beats.
Or don’t worry about tunes and just code the micro:bit to turn its acceleration into sounds that change when you move it and tilt it: