Overview


The latest micro:bit (V2) has a built-in speaker that can play sounds directly. You can also output sound from either a V1 or V2 to a pair of headphones or speaker by connecting them to the signal on Pin0


Common ways to do this are by using a set of analogue headphones with a jack plug on the end or using an inexpensive piezo speaker. You can buy an adaptor to make this easier, or improvise with common materials.


Contents


Connection

Headphones/audio jack

Connect Pin0 to the tip and GND to the sleeve of the jack. If you have four rings on the headphones, choose the top and bottom rings.


micro:bit connected to headphone jack via cables on pin 0 and ground 


Headphones/audio jack with extra connector

You can cheaply buy an adaptor from 3.5mm mono (or stereo) audio plug to crocodile clips. In this case, connect the crocodile clips directly to Pin0 and GND as above, using the black clip for GND. These adaptors may also be sold as an "audio cable for micro:bit".


a black adaptor cable going from a female 3.5mm socket to white and black crocodile clipsPiezo speaker

Connect Pin0 to the red lead and GND to the black lead of the speaker.

micro:bit connected to piezo speaker via crocodile clips at pin 0 and ground


There are lots of fun and interesting ways to connect up the headphones or speaker. If you have tried another method, let us know so we can share it in this article


This example by @kgiori shows the headphone jack inserted through the GND ring so that the sleeve of the jack is touching GND. A bent paperclip connects the tip of the jack to Pin0.

Photo showing headphones connected with a paperclip. The headphone jack goes through the GND pin hole and a bent paperclip wraps round the tip of the headphone jack and twists into place in the pin 0 hole.

This example from Daisy shows tin foil and tape being used to connect the pins to the headphone jack:

Photo showing headphones connected with tin foil and tape. The tin foil is twisted into tight cables and wrapped around the tip and sleeve of the headphone jack, connecting it to pin 0 and ground. The contraption is held together with duct tape



Programming

MakeCode

Place a play melody block from the Music menu underneath the on start block to play a melody when the micro:bit is powered on or reset.

 

Python 

Import the music module and then use music.play() to play a melody when the micro:bit is powered on or reset.

import music
music.play(music.ENTERTAINER)


Mute sound and control the volume

See our article on muting the micro:bit and controlling the volume for more information.