The snap:bit is an electronic component for the Snap Circuits educational electronic kit. It features a socket for connecting the BBC micro:bit. This allows the Snap Circuits to be programmatically controlled by the micro:bit.
This project demonstrates how to properly connect the 8Ω Speaker (SP) component of Snap Circuits to the snap:bit board. The BBC micro:bit will play the Ode to Joy on the speaker.Snap Circuits diagram
Build the circuit shown in the diagram above.Code
You can build the code yourself in the MakeCode Editor.
Alternatively, open the ready project here: https://makecode.microbit.org/_AAqUCALTjTKD
Once ready, download the code to your micro:bit. Then disconnect all cables from your micro:bit. Both the USB and the battery pack must be disconnected from the micro:bit.How it works...
The micro:bit plays music through pin P0. So the Speaker (SP) snaps must be connected across snap 0 and either the 3V or GND snap of the snap:bit.
When you close the slide switch (S1), the Battery Holder (B1) powers the snap:bit through the 3V snap and the micro:bit turns on. The “on start” event triggers and the micro:bit plays the melody. The sound is modulated as a current through snap 0, which goes through the speaker and makes it play the sound.Incorrect connection of the speaker
You must be careful to ground the speaker properly to the micro:bit by connecting it to either the 3V or GND snap of the snap:bit.
Below is an example of an incorrectly connected speaker.
Although the speaker is connected to the battery (-) and the circuit is closed (current can flow from snap 0 of the snap:bit, through the speaker, back to the battery), the melody sounds distorted, because the speaker is not grounded properly to the micro:bit.Minimal speaker connection
You can connect the speaker directly across the 0 and 3V snaps on top of the snap:bit without any additional wires.
This minimal setup is very useful when experimenting with the code and the micro:bit is connected to the computer. This way you can have just the snap:bit with the speaker next to your computer without any additional components.