 Check this out this is my homemade iPod that plays music. We've been over buzzers, we've been over speakers, then we went and combined speakers with audio amplifiers. The problem was we don't have much storage on a Arduino board so we had to stick with what we got and we played this really annoying frequency sequence out of the speaker and it sounded like crap. At the time of recording the video we had no other way of storing data other than putting it on the Arduino or having it go through the computer in the USB port and then into the Arduino which is still complicated that way. Also if you wanted to unplug it from the computer and take it somewhere else you'd lose all of the storage that you need. So I went ahead and got one of these. This is an SD card module. It allows you to take an SD card where you can put stuff on it. This one's 8 gigabytes plug it in right here send the cables to your Arduino maybe through a bed board which is what we're going to be using and now you can go and play songs off of this SD card. Originally I was thinking maybe just having some text on the SD card putting it onto the Arduino and then displaying it on the screen or something like that but I thought that was pretty boring so we're going to go and turn this into a mp3 player. There's a couple steps we're going to need to do but first make sure you have everything you need. You're going to need an SD card, SD card module. I'll put a link in the description for you guys if any of you want to buy this they're pretty cheap I got a pack of these. Speaker, an audio amplifier is preferred since it's going to play really quiet out of the speaker so this will amplify it and then an Arduino. One thing I'd like to say is this is not going to sound good at all it's going to play the song it's going to be noticeable but it's going to sound like absolute crap. Once you've got all that take your SD card out of your SD card module and then whatever method you want to use plug it into your computer. I'm just going to use this little SD card adapter and now we're going to need to put some songs on this card. You can go and get a song from anywhere you'd like I'm using Epidemic sounds and this is not me shilling for them or anything it's just copyright free music and I'm on YouTube so I need to be using copyright free music. So we're going to go and take the first song here and just download it straight to our computer download the full mix and once it's done downloading we're going to go to this website here and I'll put the link again in the description for you guys where we're going to go and down sample the song into a format that we can play on the Arduino. One of the reasons I'm saying that is because the Arduino isn't like a full surround sound system it can only do mono audio and it can do it at a very low bit rate. So we're going to go here and change this to 8-bit we're going to go and change this to 16,000 Hz and make sure it's on mono obviously then in your PCM format go all the way to the bottom to unsigned 8-bit. Now you can find whatever song you'd like so we're going to take the one we downloaded earlier and drag it into here and then we can convert it once it's done uploading. So it's done uploading let's go ahead and convert it it takes a couple seconds and you'll see it'll pop up in your downloads folder. When it's in your downloads folder I recommend you rename it to something really short and memorable. I just put the number one so it's going to be one dot wave. Turns out I actually have another one so let's go and just rename it another number. Let's go with number five for example so five dot wav so we just have to find our drive at the bottom here USB drive right here d it has a couple songs on it so I'm going to go and remove those and then in downloads we can replace those two that we just deleted with the song named number five. You should format your USB drive to be x fat or fat 32 it's really easy you just right click on it and then go format and then click the settings in there. Once you're done with that all you got to do is take this d-card out of your computer and then plug it into the Arduino and now you're ready to pull sound or at least data off of this SD card. Wiring everything up can get a little complicated so we're going to break it down into steps and we're going to use a breadboard to kind of organize everything. I have a speaker with a power and a ground which goes into the amplifier and then out of the amplifier I have three cables a power which is the red cable a ground which is the blue cable and then the audio in which is this purple cable on your breadboard in the red row at the top go ahead and plug in anywhere your power in or your 5 volt for your auto amplifier and then you can plug in your ground into the blue line on the board right there. It's a purple cable we can leave it for now let's go ahead and get our SD card module and we're going to plug that into the breadboard. There are different types of SD card modules this is the one I have a CS, SCK, MOSI, MISO, VCC and ground if you have a different one just search up the schematics for this one it's usually not that complicated but the code is pretty similar so we're going to take that and we're going to plug it in into the board right over there. So let's get a couple cables and then we're going to start plugging in our module sensor into our Arduino. So get a couple cables and on the screen I'm going to put a little text or picture of which port you should plug into which port from the module to your Arduino but I'll show you anyways how to do it and I want to plug into the first one which is CS it's going to go into port number 10 on the Arduino just go ahead and plug that in then our next one which is SCK it's going to plug in right here and that's going to go into 13 on the board then our next one which is MOSI MOSI is going to plug into 11 then the next one MISO MISO is going to plug into port number 12 on the Arduino. So you have CS going to 10 SCK going to 13 MOSI going to 11 MISO going to 12 then you're going to have the last two which is VCC power is going to be going directly into the power line on the breadboard so you could just plug it in right next to audio amplifier that we plugged in earlier and then we're going to need one more cable for our ground which is going to plug into the blue side of the breadboard as well just like earlier with audio amplifier. Then you can take your SD card module and you could just stick it back in I took it out because it's a little tight in here and make sure it's nice and tight in there on your breadboard after that go ahead and grab your audio amplifier and plug in your purple cable or your in cable on the board into port number nine on the Arduino and that's going to be our audio out pin so we're going to be taking all the information off of the SD card putting it into the Arduino and then sending it out through the purple cable or through your in cable into the audio amplifier and that's going to amplify the signal and send it to your speaker and play music. Now plug in your Arduino into your computer and let's write some code so that we can actually go ahead and play some music through the speaker. The last step is to go and plug in into our breadboard the power and ground cable so that we're actually giving power to our two modules which is the SD card and the audio amplifier. So we're going to go and grab one cable and plug it into our five volt and then plug in our five volt into our breadboard and then we're going to grab another cable put it into our ground and then take that and plug it into the ground. Now we could see a light turn on and the speaker just made a little squeak letting me know that there's actually power going through the circuit. If you don't understand what's happening on the breadboard you have two rows at the top here and two rows at the bottom with a plus and minus next to them and then a color so blue and red. When you plug into let's say the first pin on the top row here it will now activate this whole row if it's a power pin. So in this case we're putting one power pin into this whole row and then a couple pins which are going to be pulling out power so it's just a way of using this as a splitter pretty much. Now that we got that working let's go into our Arduino editor write some code so that we can actually process the music and put it into the speaker. The first thing we need to do in our Arduino editor is include a couple different things. The first thing is we want to go and include an sd library so we're going to do this sd.h. I'm going to go and include this one library called tmr and then lowercase pcm.h and then one last one which we're going to include again is going to be the spi. If you don't have any of these libraries pre-installed just go into tools manage libraries and then search up sd tmr pcm and spi and go and install them one by one. Then as always when we use a library we're going to call it and we're going to set it to a variable at least an instance of it. So let's go and call this tmr pcm and now we have this variable that we can use throughout our program. The first thing we're going to do in our setup is we're going to call that variable. Once you call that variable let's go and call speaker pin on that and then let's set our speaker pin to nine which was the purple cable or the in cable coming out of the amplifier. Next up let's go and activate our console quickly so we'll just do serial dot begin as always we've done in every project on this channel and we're going to call 9600 comma in the back here and on the next line we're going to need to make a little conditional that says if something's wrong with our sd card tell us. So the first thing is to go in here and then call sd dot begin and we're going to need to call it on our sd card which we plugged into port number 10. So a couple things we're going to need to do first is go on the top here and call our cs pin into 10 and then down here we can go and call cs and in our if statement in our conditional here we can just tell it to tell us something like error with the sd card and then just return an empty out of the function. So now if we can't begin on our sd card we can't run anything on it on that port it's going to throw an error and then it's going to jump into here and say error with sd card so we're notifying ourselves if something's wrong with our sd card and we'll know that's the problem and it's not the audio amplifier or the speaker or at least if we can get rid of that we can break it down to maybe it's something wrong with the speaker the audio amplifier. It's just process of elimination making sure that everything's set up properly. Then in here let's go and call our variable again tmr pcm dot set volume you could do anything between 1 to 10 here i'm going to go and put a 5 under that we're going to call tmr pcm again and we're going to call play and in here you can go and put that name of the song that you put on your sd card. I put five dot wave so we're going to do that and now we're ready to go as always in these videos this is just me automatically activating it the second the Arduino turns on but you can run it with a button you can have a sensor run it so let's say you use that sensor from the outdoor light video when someone walked in front of the temperature sensor it was able to see that somebody crossed in front and then it turned on the light let's say instead of turning on the light or with turning on the light you had it play a sound like emergency and true to alert or something like that you can really go crazy with this but this is how you activate it just normally so the second Arduino turns on and activates the setup function it's going to go check if this d card's okay and then play the song we hear the Arduino making a couple little beeps let me just grab the mic here now we're getting music coming out of our speaker it doesn't sound very good it's very noisy here so it sounds like with absolutely no audio effects but it's not too bad you can also get another one of these and then do a right speaker a left speaker and then send that signal to earphones for example then all you need to do is three different a case for the Arduino and now you have a music player that you can use on the go then all you got to do if you want to start the song from scratch is press the reset button on the Arduino or unplug it and re-plug it and it'll start from scratch if you enjoyed this video thank you so much for being here maybe consider giving it a like and subscribing to the channel i'm going to be posting more content showing you how to do cool things with electronics hopefully some cool meme robots coming in soon i'll see you guys in the next one