Last active
February 10, 2016 16:09
-
-
Save mpflaga/5800976 to your computer and use it in GitHub Desktop.
Simple example of playing a sequence of tracks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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