Using our website means you agree to using cookies which help us improve microbit.org.Learn more
Skip to content

Activity

Jukebox

Intermediate | MakeCode, Python | Buttons, Pins, Sound | Input/output, Sound

Step 1: Make it

What is it?

Make a music machine that plays different tunes at the push of a button.

micro:bit showing musical notes when button A or B pressed

How it works

  • A jukebox is a machine that plays different songs when you put a coin in and choose which tune you want to hear by pressing buttons.
  • This micro:bit jukebox uses headphones or speakers connected to make sound like we did in the Make some noise project.
headphone plug tip connected to micro:bit pin 0, long part of headphone plug connected to GND on micro:bit
  • Connect micro:bit pin 0 to the tip of your headphone plug, and GND to the longer part of the headphone plug.
  • When you make sound with the micro:bit, pin 0 becomes an output.
  • This program plays different built-in tunes if you press input button A or button B.

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

Step 3: Improve it

  • Change the tunes, for example try PRELUDE or ENTERTAINER. You can find a list of all the built-in tunes you can use in Python here.
  • Show different pictures, letters, numbers or words depending on which tune you picked.
  • Make it play a random tune if you shake it.