Step 1: Make it
What is it?
Make a music machine that plays different tunes at the push of a button.
These two videos show you what you'll make and how to code it:
Introduction
Coding guide
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 the A and B button inputs to play different built-in tunes.
- If you have a micro:bit V2 with built-in speaker, you'll hear the sound straight away. You can also attach headphones to any micro:bit using crocodile clip leads:
- 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.
What you need
- micro:bit (or MakeCode simulator)
- MakeCode or Python editor
- battery pack (optional)
- a pair of headphones and two crocodile clip leads (optional)
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 different tune if you shake it, press buttons A and B at the same time, or press the micro:bit's touch logo.
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.