#574 MicroSD WAV Player
A basic demonstration of playing a sound file (WAV) from an SD card with an Arduino.
Here’s a quick demo..
Notes
Microcontrollers generally have very limited memory, so playing audio samples of any complexity usually requires external storage. An SD card is a convenient option, as it can easily be prepared on most computers.
This is a quick test of an SD card reader with an Arduino to play an audio file from the SD card.
MicroSD Card Module
I’m using one of the very common Micro SD card reader modules from an aliexpress seller.
The module uses SPI, and includes level shifting and regulation so that it is 5V tolerant.
Feature | Min | Nominal | Max | Unit |
---|---|---|---|---|
Supply Voltage | 4.5 | 5 | 5.5 | V |
Current | 0.2 | 80 | 200 | mA |
Supported cards | MicroSD < 2Gb | MicroSDHC < 32Gb |
Construction
I’m just using a pieze buzzer for output, without any current limiting resistor R1 (may be required depending on the piezo component). Of course, any other audio output device could be substituted here.
Code
The TMRpcm Library does all the heavy lifting of reading the sound file and streaming the audio output. It uses the Arduino SD Library under the covers.
I’ve kept the demo code in WavePlayer.ino
super-simple - it just plays a single given file (SAMPLE.WAV
) when the push-button is pressed.
Preparing the Audio
I’m using a short sample - included in the sample
folder as an Audacity project.
The sample has been reduced to mono 16kHz, and exported to sample.wav
as an unsigned 8-bit PCM file.
This file is then written to the SD card.