So I had a project in mind for a while I love working with lm386 chips and working on making better audio with it so I decided the best route to do that was to make a custom arduino audio player that I could connect my lm386 audio boards to it and be able trouble shoot design and test with it. Having this available to test was a awesome making the SD Card player to test out my boards so I can incorporate them into further projects and assure they are working 100% before doing so. Now why would I do that when the kids are really cheap? Well because its fun and great for learning and teaching about electronics. So I have decided to use this as my main prototyping setup for it and will add some features here and there as I get parts in so that I can fully use it to my advantage. The Arduino is a wonderful tool to help with prototyping and designing with ease. I certainly wouldn't have thought I would have gotten into them so much. But I have, and grateful for being able to design and implement things quickly with it versus having to go other routes. Plus if I blow a arduino its not going to be the end of the world instead of a expensive board that I might not be able to replace quickly.
So I started with making the SD Card Reader / uploading the player to the arduino. (I decided to use the pinout and files from Bitcows | DIY SD Card Reader and audio player for Arduino UNO )
Files needed to talk to the card to play music: https://github.com/djmason9/TMRpcm
You will have to add this to your arduino library.
Connecting the pins as taken from the site there:
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
Uploading the code for the arduino is as follows once again you can either follow along here or on the website to create this.
#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(){
}
I used pin 9 on the board to output the audio file to the lm386 audio board, not sure if other pins would be more ideal but haven't tested this further. I mounted it to the right hand side of the arduino so I would be able to solder and test and diagnose any issues I may have with out covering up the sd card area. So now with my LM386 audio board on I had to wire it up I think I will make connector posts on the SD Card board after might be a better route as well a add a more suitable speaker setup for portability. I used a 3.5mm headphone jack to output to my speaker. (I will be adding an on board output for the speaker at some point as well.)
Now that its setup and working I am excited to continue to design and create more lm386 audio amplifiers in the future. I think they did a great job on making the files and program for arduino and it was by far the best I had seen for a tutorial to get going.
For creating my wave files I used
https://www.online-convert.com/result/104d5cd3-3416-45b8-a470-3265bbe7eedb
Which was a great help getting my test files made.
audio files need to be: Sample Rate: 16000 kHz, Bit Rate 8 bits per sample, Mono
I also used the https://lingojam.com/StephenHawkingVoiceGenerator For creating my initial wave file after converting it to the right format with the online convert which then transferred over on to my FAT 2gb MicroSD card I was good to go to test out my board.
Now I just want to state I made this for making lm386 audio boards so I could have bought another shield for the arduino that had that but wasn't the route I wanted to go I wanted to keep it so everything was as cheap as possible and made by me. If Something goes wrong it wont be hard to figure out what the issue is. Plus making it vs buying it is always fun.
I know for this project I used other peoples work but really when it came down to it this was the first time I had done this and would certainly like to learn more of the software end of it after as well as possible redesigns of the sd card board to house more things that might have more use to me for testing and procedure.
Thanks for checking it out its nothing amazing but was fun to build.
Top Comments