SD Card Module
In this post we are going to see how to connect SD card module to Arduino Uno and play songs. The things needed are : SD card reader, SD card module, SD Formatter (free software) and microSD card. The Arduino library that was used is from the following link:
The downloaded zip files also contains tools to convert wav files to AFM files for playback by the SD module.
SD card module and MicroSD |
Card Reader |
The post will be divided into 3 sections:
1. Connection between SD Module and Arduino UNO
2. Preparation SD card and AFM audio files
3. Arduino code for songs/voice playback.
Connection between SD card module and Uno
As for the speaker, I used a computer speaker that cost about $5 dollar and cut the USB connector and connected the audio wire to pin 9 of Arduino. I guess only this pin can be used.
Preparing the SD card and audio file
Use the free program SDFormatter to format the SD card before use.
The best way to ensure this is to do a fresh and full format of the card (don't use quick format!). After formatting the SD card, only copy new files on it. Don't delete files and avoid rename operations that creates file names. All files must placed in root directory as folders are not supported by the audio library.
Firstly create a .wav file . In my case I used an app in the mobile called AVR (Awesome Voice Recorder) to record voice. The format produce by this app is .m4a. Then this format is converted to wav format by using an online converter which is available from this link: https://online-audio-converter.com/.
Once the wav file is ready, open the SimpleSDAudio library folder. The following files can be found inside it. Click on tools and then on Arduino with 16MHz.
Copy the wav file inside the Arduino with 16MHz folder.
Now drag the wav file and hover it on the FullRate@16MHz_Mono.bat. That is it. An AFM will be created automatically inside the converted folder. Now the AFM file need to be copied on the SD card. Place the microSD card inside the SD card reader and connect to you computer. Copy the AFM files to the SD card. Remove the MicroSD card and insert it to the SD card module which will be connected to the Arduino Uno.
Arduino Code for song/voice playback.
#include <SimpleSDAudio.h>
#include <arduino.h>
boolean play = false;
void setup()
{
if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER))
{
while (1); // Error while initialization of SD card -> stop.
}
//replace testing.AFM with your audio file
if (!SdPlay.setFile("testing.AFM"))
{
while (1); // Error file not found -> stop.
}
}
void loop()
{
if (!play)
{
SdPlay.play();
delay(10000);
play = true;
SdPlay.stop();
}
}
Ok. Hope it works for you too. If you still need further clarification, you can email to me.
Good entrepreneurs cut up check their gross sales pages and have come to the conclusion that utilizing audio merely makes the potential purchaser really feel extra comfortable and forges a relationship that's not potential with textual content alone. If you want to learn more about this topic, then please visit onlineconvertfree.com
ReplyDelete