Skip to content


Make some noise

Intermediate | MakeCode, Python | Pins, Sound | Hardware & software, Input/output, Sound

Step 1: Make it

What is it?

Attach headphones to your micro:bit and make music!

diagram showing tip of headphone plug connected to micro:bit pin 0 and the long part of headphone plug connected to GND on micro:bit

How it works

  • To make sounds with micro:bit, attach headphones or a speaker. Clip the tip of the headphone plug to pin 0 on micro:bit. Clip the longer part of the headphone plug to the GND pin on micro:bit.
  • Use this program to make your micro:bit play one of its built-in tunes when you press button A.
  • The gold pins on the bottom of the micro:bit are used for inputs and outputs. Here we use pin 0 as an output. The micro:bit sends pulses of electrical signals from pin 0 when it plays the tune. The headphones must also be connected to the GND pin on the micro:bit to complete the electrical circuit.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • a pair of headphones, buzzer or amplified loudspeaker
  • two crocodile clip leads

Step 2: Code it

1from microbit import *
2import music
4while True:
5    if button_a.was_pressed():

Step 3: Improve it

  • Try different tunes like ODE, BLUES or BIRTHDAY. You can find a list of tunes you can use in Python here.
  • Make the tune repeat more than once using a loop.
  • What happens if you connect pin 0 to the middle part of the headphone plug instead of the tip?