MakeCode Audio

Crickit provides an amplified audio output via the Speaker block.

 

For the Circuit Playground Express + Crickit version, we take advantage of the CPX ability to play WAV files over the true-analog output pin A0.

The micro:bit version of Cricket also has amplified audio output.

 

The micro:bit is not shown in the diagram at left, just plug a micro:bit into the slot in the middle of Cricket in the direction indicated.

 

The audio pin used on the micro:bit is pin P0 which has a small speaker icon on it on the Crickit where the micro:bit pin numbers are listed.

Audio animatronics! By adding a voice or sound effects to your robot you can make a cool interactive project. 

This is one of the few outputs that does not go through the Crickit's seesaw helper chip. Instead, the audio is played directly from the microcontroller board and the Crickit amplifies it!

Amplifier Details

The onboard amplifier is a mono "Class D" audio amp with BTL (Bridge Tied Load) output.

That means you cannot plug the speaker output into another amplifier, it must connect directly to a speaker!

You can use just about any 4 to 8Ω speaker (6 Ω is OK too, just not as common). The amplifier can drive up to 3 Watts into 4Ω and 1 Watt into 8Ω. That means its ok to drive a 5 Watt speaker, it just wont be as loud as it could be with a bigger amp (but you wont damage the amp). You can also drive speakers that are smaller, like an 8Ω 0.5 W but make sure you don't turn the audio volume potentiometer up, as it could damage the speaker by overpowering it.

Playing Sounds on Crickit with MakeCode

If you are using a Crickit with Circuit Playground Express (CPX), the Crickit becomes an amplified extension of the regular audio out. The sound is very clear and the volume can be higher than the CPX on-board speaker. Below I've taken a cute song snippet and reduced the volume from a previous value of 100 to 34 so one's ears don't hurt when it starts. If the slide switch is moved left (towards the on-board speaker on CPX), the song will play, moving the switch right silences it. If you think the speed of the sound (the tempo) is too fast, press button A to slow it down. If you think the tempo is too slow, press the B button.

Circuit Playground and Feather Crickit Version (micro:bit below)

You can download the code by clicking this link to link to the MakeCode website.

Check out all the music blocks, you can have Crickit using sounds in projects with just a couple of clicks!

micro:bit Version

The blocks available for music are a tiny bit different:

There is no set volume block in MakeCode for micro:bit, so your volume is quite loud. It is suggested that you do not play tones forever like the example below to save your sanity.

Here is the song code for micro:bit:

This guide was first published on May 16, 2018. It was last updated on May 16, 2018. This page (MakeCode Audio) was last updated on Oct 18, 2019.