Created
July 31, 2014 22:14
-
-
Save microtherion/194b92549496616eb649 to your computer and use it in GitHub Desktop.
This file contains 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
#include <SPI.h> | |
//Add the SdFat Libraries | |
#include <SdFat.h> | |
#include <SdFatUtil.h> | |
//and the MP3 Shield Library | |
#include <SFEMP3Shield.h> | |
/** | |
* \brief Object instancing the SdFat library. | |
* | |
* principal object for handling all SdCard functions. | |
*/ | |
SdFat sd; | |
//create and name the library object | |
SFEMP3Shield MP3player; | |
byte temp; | |
byte result; | |
char title[30]; | |
char artist[30]; | |
char album[30]; | |
void setup() { | |
Serial.begin(9600); | |
//Initialize the SdCard. | |
if(!sd.begin(SD_SEL, SPI_FULL_SPEED)) sd.initErrorHalt(); | |
// depending upon your SdCard environment, SPI_HAVE_SPEED may work better. | |
if(!sd.chdir("/")) sd.errorHalt("sd.chdir"); | |
//boot up the MP3 Player Shield | |
result = MP3player.begin(); | |
//check result, see readme for error codes. | |
if(result != 0) { | |
Serial.print("Error code: "); | |
Serial.print(result); | |
Serial.println(" when trying to start MP3 player"); | |
} | |
pinMode(A0, INPUT_PULLUP); | |
MP3player.setVolume(2, 2); | |
} | |
void loop() { | |
while (digitalRead(A0)) | |
delay(10); | |
//tell the MP3 Shield to play a track | |
result = MP3player.playTrack(3); | |
Serial.println("Go!\n"); | |
//check result, see readme for error codes. | |
if(result != 0) { | |
Serial.print("Error code: "); | |
Serial.print(result); | |
Serial.println(" when trying to play track"); | |
} | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment