Zuletzt geändert am 26. Juni 2012 um 20:10

Play audio files with your Arduino in decent quality from SD card, only very few additional hardware required.

Features

  • 8-Bit PWM output - no external DAC required
  • 62.500 kHz (fullrate) / 31.250 kHz (halfrate) sampling rate @ 16 MHz
  • 31.250 kHz (fullrate) / 15.625 kHz (halfrate) sampling rate @ 8 Mhz
  • Mono, bridge and stereo mode
  • RAM usage ~1.3 kByte
  • ROM usage ~6.1 kByte
  • Integrated SD library (minimal FAT only, optimized for low RAM usage and high performance)
  • Works with most SD card shields that are hooked to SPI port
  • Easy to use: 1. init library, 2. select audio file, 3. call play, 4. call worker while audio is playing
  • Supports SD and SDHC cards formated with FAT16 or FAT32

Restrictions

  • Audio file must be converted prior use
  • Audio files must reside in root directory of card
  • File name of audio file must be in 8.3-format
  • Audio file must reside completely non-fragmented on card
  • fullrate and stereo actually leads to buffer underruns

Quickstart guide

  • Install library: Unzip all to your /libraries/ folder.
  • Copy file /libraries/SimpleSDAudio/examples/example.raw to root folder of a freshly formated SD card (don't use quick format!)
  • Connect SD card to your Arduino board (using shield or whatever, SD card's chip select should go to pin 4, all other to SPI pins)
  • Connect a speaker, headphone or line-in via 100 ohm resistor in series to audio output pin (pin 9 on Arduinos with ATmega168/328, pin 44 on Arduinos with ATmega1280/2560). Connect other end of speaker/ground of line-in to GND
  • Launch Arduino IDE and try example "BareMinimumWithDebug" first
  • You should hear some audio. Activate serial monitor to find some information if it does not work. Maybe you have to adjust SD cards CS pin in sketch.

Software installation guide

Preparation of SD card and conversion of audio files

Hardware setup