micro:bit Tone Amplifier
The micro:bit music blocks control the pin P0
. This current from this pin needs to be amplified in order to play in large speakers. Fortunately, the micro:bit produces very basic sounds (square sound waves) that can be amplified with a single transistor.
This module is built like the relay.
Code
The code below plays a “power up” melody when button A is pressed and “power down” when button B is pressed. The speaker should be connected
to the MOSFET connected to the pin P0
.
Click on Download to transfer the code to your micro:bit