Introduction: MP3 Player
The LinkIt ONE development board by MediaTek is the perfect platform for an MP3 player. It has SD card Read/Write capabilities, can play audio files, and has plenty of room for code and hardware!
I am going to show you how to play Audio files from an SD card on the LinkIt ONE board. You will need:
- Micro-SD card
- LinkIt ONE Board
- Headphones or speakers
Step 1: Setting Up Your SD Card
This step won't take long but is very important. You must format your SD card to FAT. This is the file format that your board understands. Simply right click the drive once you plug it in your computer and select format. Then select FAT or FAT32 and format. Your SD card should also be class 10 or above.
At this point you can also load the audio files onto your SD card that you want to play. In the code the files are called 1.mp3, 2.mp3, etc.
If you are playing another file type such as ".wav" then you will need to change that. Also, you will either need to change the song names to numbers or the numbers in the code to your song names. I would try the latter first because I had an issue with the titles because the board does not like spaces or special characters such as hyphens.
Step 2: Wiring
This MP3 player's goal was simplicity. So, there is only one button which skips tracks. That way instead of having a confusing interface you can focus on the point of the project, the audio you are trying to listen to. Simply wire a push button to digital pin 2. The exact wiring is as follows:
- On one side there is a wire to 5v
- On the opposite side there is a wire connected to a resistor of any value which then goes to GND
- On the same side as step 2 there is a wire to pin 2.
Step 3: Code
Below is the code you need to get your MP3 Player up and running. Basically what is does is wait for you to push a button. Once you do it starts playing the first song in the list. When you press again it will play the next one.
In order to get your player working you will need to change two things:
- The number of songs you have to play
- The name of the songs
There is variable called playlist that holds the number of files to play. Change this to your number of files. Also, change the names of the files in the code. See the pictures above for reference.
Attachments
Step 4: Setting It Up
Now, you are almost done. Find a pair of headphones, or a pair of 3.5mm equipped speakers and plug them into the audio jack. Plug your sd card in and switch the SD/SPI switch to SD. Lastly plug a power source into the board. Either the usb cable or the battery. If you decide to use the battery be sure to switch USB/BAT to BAT.
Does it work? Awesome! If not check these things:
- SD card formatted to FAT?
- Correct File names in code?
- If the above are done does changing the audio file's names to one character like "1.wav" work?
- Is there a short in the headphones? :-)
- Is the SD/SPI switch set to SD?
- Did you wire the button correctly?
- Is your SD card class 10 or above?(not strictly necessary but helps)
Hopefully you got it working! If not the comments box is open!