Files needed to talk to the card to play music:
https://github.com/djmason9/TMRpcm
You will need to install these into the Arduino App. (See Import Library) for details
Don’t have a break out board for the card reader? Make one! NOTE: only use 3.3V on this.
Connecting the pins
Arduino Pins | Card Pins pin 10 | 7 | CS / DAT2 / pin 11 | 6 | DATA IN / CMD pin 12 | 1 | DATA OUT / DAT0 pin 13 | 3 | CLK / SCK 3.3v | 4 | VDD / VCC / PWR GND | 5 | VSS1 / GND ----------------------------------------- GND | 2 | GND
Card Pins Start 1-7, 1 being the side without the angle
#include <pcmConfig.h> #include <pcmRF.h> #include <SD.h> // need to include the SD library #define SD_ChipSelectPin 10 //using digital pin 4 on arduino nano 328 #include <TMRpcm.h> //also need to include this library... TMRpcm tmrpcm; // create an object for use in this sketch void setup(){ tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc Serial.begin(9600); if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized: Serial.println("SD fail"); return; // don't do anything more if not }else{ Serial.println("SD read"); tmrpcm.play("someaudio.wav"); } } void loop(){ }
Its important to note that you need to set up your audio files correctly.
– Sample Rate: 16000 kHz
– Bit Rate 8 bits per sample
– Mono
The best way to do this I have found is to use iTunes.
To learn more about how to read and write to the sd card check out this artical