As I discussed in a previous post… I was trying to get my Arduino to play music. I attempted to build and use an Arduino Wave Shield and FAILED. But yet.. I have managed to overcome such a feat and now I got my Arduino playing music. And thats not even the best part. The real icing on the cake is that… (wait for it, wait for it) …. IT IS ALL DONE USING NODE.JS! (Crazy right? I thought it was almost impossible).
How can you turn your Arduino into a music player using Node you ask?
Well first you need the right shield. The one I bought is from a third party seller (not from Adafruit or Sparkfun), but actually from a company on ebay. It is compatible with the Sparkfun MP3 Shield library, so you really could buy either one for this example to work (the one I bought is cheaper though).
Though I have provided the Sparkfun MP3 Shield library, we know that Arduino sketches are not written in Node… so let me spill the beans on how its done:
The answer is Paul DeCarlo. Paul is also a Technical Evangelist who helped put this together for me when I was in crisis(WHOOP WHOOP! Go Paul). Using Serial Port, he was able to communicate to the Arduino Shield using Node with these 7 simple steps:
Before you can jump into it though, you will need a few things set up. First, be sure you have a microSD card inserted into the MP3 Shield, with file names such as track001.mp3, track002.mp3, track003.mp3. (If you do not format your file names as such, the shield will not read the file names properly and you will not be able to play any tracks. And yes those are zeros). Secondly, you will need to be sure you have the Arduino IDE installed onto your computer; you will need it for Step 4. And lastly you will either need a pair of headphones or speakers to plug into the shield, or else you wont here much of anything.
Some extra tips and hints:
- In step 4 it says to use the MP3Shield_Library_Demo sketch, but considering the Sparkfun MP3 Shield library does have other sketches, you have options and you can test the code with the other sketches
- In step 5 to find your port value go to your Arduino IDE => Tools => Port and you will see the port to your Arduino listed. If you are using a MAC, the port value will not be a COM value but rather look something like this: /dev/tty.usbmodem1411 or /dev/cu.usbmodem1411. If your port value shows a cu. , replace it with tty. in the code or else your Arduino will not be found.
You can find Paul’s code here. Feel free to download it and have a blast jamming out. Also you should totally check out Paul DeCarlo’s page for more info on how to do IoT and various other hardware projects.
SideNote: As the NodeBot Adventure posts have continued, I have not yet told you how all these pieces are coming together. But soon, I promise you I will reveal the final project. Stay tuned.