Speaker

Overview

Age Range: First time using external devices for the micro:bit

The MakeCode editor has a dedicated tab to making music and sounds with the micro:bit. Using the external speaker, students will learn the basics of how the music tab works and how sounds can be produced from the micro:bit.

Aims

  • Gain a basic understanding of the music tab in the MakeCode editor.
  • Create music using the micro:bit and external speaker.

Download the Code

Click the button below to download the MakeCode editor code for this lesson. The hex file is contained in a zip folder.

Kindly refer to our download the code page for instructions on how to upload your code onto the micro:bit. Please use instructions set A.

This code can also be uploaded into the MakeCode editor.

Kit Required

Micro:bit

Mini Innovation Board

Speaker

  • MicroUSB Cable
  • 1 x Connector Cable

Preparation

  1. Connect the micro:bit to the Mini Innovation board via the edge connector.
  2. Use the connector cable to connect the speaker to the ADC1 connector on the Mini Innovation board.
  3. Connect the micro:bit to a computer via the microUSB cable.
  4. Go to the MakeCode website on your computer and open a new project.

Time to Code

As you go through these steps please note that there are images of the completed code to the right.

  1. Firstly select the ‘on button pressed’ block from the ‘inputs’ tab and select button A from the drop down. Students should be familiar with this block by now.
  2. Next, go into the ‘music’ tab and select the ‘play tone’ block. Insert this into the ‘on button pressed’ input. By default, middle C is the tone selected but feel free to change this. Leave the default, 1 beat.
  3. Then, select another ‘on button pressed’ block from the ‘inputs’ tab. This time choose button B from the drop down.
  4. Open the ‘music’ tab again and select the ‘start melody’ block. Insert this into the ‘on button pressed B’ input. Choose any of the melody options from the drop down but leave the repeat to once.
  5. The code is now finished! Download the code and upload it onto the micro:bit. The instructions for this can be found on the download the code pagePlease use instructions set B.

What Will Happen

When button A is pressed a tone will play from the speaker for 1 beat. When button B is pressed a melody will play once.

Taking it Further

  • Explore the ‘music’ tab further and experiment with other blocks available.
  • Use the skills learned to help complete the more advanced control lessons.

Keep in touch

We would love to keep you up to date with all of our latest news, offers and new products.

If you would like to subscribe to our mailing list please click the button below.

Contact Us

ScienceScope Limited
Downside School
Stratton-on-the-Fosse
Radstock
BA3 4RJ
enquiries@sciencescope.uk

Follow Us

#digitaleducationjourney