A micro:bit v2 can record, playback, and graph sound sound. While it only has enough RAM memory to record about 1.5 seconds of sound and the sound is not very loud through the built-in speaker, this project makes a great introduction to digital sound. A small amplified speaker, such as the inexpensive portable speakers sometimes used with mobile devices can be used to make the sound louder.
Record when button A pressed:
Playback when button B pressed:
Graph the recorded sound:
Assemble the scripts above or download and open the project.
Or drag and drop the picture below onto the IDE:
Press the A button to record about 1.5 seconds of sound.
Press the B button to play back the recorded sound through the built-in speaker. It isn't very loud so you may need to hold the micro:bit close to your ear.
You can make the sound louder using a small, self-amplified speaker like this $5 "Hamburger Mini Speaker" (https://www.sparkfun.com/products/14023)
Connect the speaker to pins 0 and GND using alligator clips and change the pin in the playback script from 27 to 0 to make the sound play through the speaker.
Pro Electronics Trick: Connecting a small (~1-10 uF) capacitor in parallel with the speaker input will remove some of the roughness from the sound. The capacitor acts as a low-pass filter to "smooth out" the sound waveform generated by the micro:bit.
Open the graph and click the graph script to graph the recording.
The graph shows the sound samples that were recorded from the microphone. The microphone converts the tiny fluctuations in air pressure created by sound waves into a varying voltage, which micro:bit reads as numbers. The record script stores those numbers in a list of 20,000 sound samples. To capture the details of the sound, it records about 10,000 sound sample every second.