Load some MP3 files
Copy 2 MP3 files to a micro SD card and name them track001.mp3 and track002.mp3 (this is just for the test, you can re-name them later). Then push the uSD card into the slot on the shield
The SD library for Arduino can only handle 8.3 names, that means you can name your file track001.mp3 (8 letters dot 3 letters) but not MyFavoriteMusic.mp3
Make sure you have a good quality SD card, some cheap SD cards won't work, causing confusion! Especially 'non-brand' knockoffs.
Simple Audio Player Sketch
Connect the Arduino to your computer with a USB cable and plug your headphones into the headphone jack. Select File->Examples->Adafruit_VS1053->player_simple to load the example code.
We originally wrote the library for use with the Breakout board. Since the pinout's a little different we just need to make a minor change. Find this line:
Adafruit_VS1053_FilePlayer musicPlayer = // create breakout-example object! Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS); // create shield-example object! //Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
and change it to:
Adafruit_VS1053_FilePlayer musicPlayer = // create breakout-example object! //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS); // create shield-example object! Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
To use the shield pinouts. Now upload the example. You should see the following:
And audio playing from the headphone jack.
If you get
If you get
Adafruit VS1053 Simple TestCheck that you commented out the breakout line and uncommented the shield line so it knows you're using a shield!
Couldn't find VS1053, do you have the right pins defined?
Interrupt/Background Version
Advanced users can also run File->Examples->Adafruit_VS1053->player_interrupts. This example demonstrates playing files in the background using interrupts. This allows you to do other things in your sketch while the music plays! It also has more error reporting and lists all the files found in the SD cardDon't forget to do the same thing, updating the:
Adafruit_VS1053_FilePlayer musicPlayer = // create breakout-example object! Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS); // create shield-example object! //Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
to:
Adafruit_VS1053_FilePlayer musicPlayer = // create breakout-example object! //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS); // create shield-example object! Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
You can see the output is more detailed - it also lists the names of the cards on the SD which can help if you're having problems naming the file:
Page last edited May 16, 2014
Text editor powered by tinymce.