Fork me on GitHub

Project Notes

#574 MicroSD WAV Player

A basic demonstration of playing a sound file (WAV) from an SD card with an Arduino.

Build

Here’s a quick demo..

clip

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  

module_functional module_image

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.

Breadboard

Schematic

Build

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.

audacity_export

Credits and References

About LEAP#574 AudioArduinoSD
Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.