Skip to content

Instantly share code, notes, and snippets.

@mpflaga
Last active February 10, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpflaga/5800976 to your computer and use it in GitHub Desktop.
Save mpflaga/5800976 to your computer and use it in GitHub Desktop.
Simple example of playing a sequence of tracks.
// libraries
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
// initialize MP3 card
SdFat sd;
SFEMP3Shield MP3player;
byte result; // variable for mp3 player shield, can be used to debug
// setup
void setup() {
if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
if (!sd.chdir("/")) sd.errorHalt("sd.chdir");
MP3player.begin();
MP3player.setVolume(10,10);
}
// loop
void loop() {
for (int i=0; i <= 255; i++) {
if(!MP3player.playTrack(i)) { // if it returns an error move on to next track.
while (MP3player.isPlaying());
MP3player.stopTrack();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment