Home Forums Sparkfun MP3 Shield Library Support Forum MP3 Shield bugs on an UNO

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #2817

    Hi all,

    I’m not certain if it’s my code (reproduced below) or the board or the library or what, but I’m having a devil of a time getting this circuit to work. In practice, it’s simple: Motion sensor trips, lights and sound come on. Haunted house stuff. But:

    1) the MP3 suddenly stops playing after ~.85 seconds (+/-.03 seconds)

    2) THEN I get the error “If you get this error, you likely do not have a sd.begin in the main sketch, See Trouble Shooting Guide!

    3) Originally, when I was building this circuit, the MP3 worked. Then I put my wires into pins 9 and 10, and suddenly it all came crashing down.

    I am probably making every possible mistake in the world, and I apologize in advance as I’m just starting to learn this stuff. What am I doing wrong?

    Thanks for your help!


    Code Reproduced:

    #include <SPI.h>
    #include <SdFat.h>
    #include <SdFatUtil.h>
    #include <SFEMP3Shield.h>

    SdFat sd;
    SFEMP3Shield MP3player;

    boolean playing = false;
    float totalPlayTime = 10000;
    float playStartTime = 0;
    int modetectPin = 5;
    int modetectVal = 0;
    int spotLightPin = 10;
    int pulseLightPin = 9;

    void setup() {
    pinMode(modetectPin, INPUT);
    pinMode(spotLightPin, OUTPUT);
    pinMode(pulseLightPin, OUTPUT);
    sd.begin(SD_SEL, SPI_HALF_SPEED);

    void loop(){


    if(motionActive() && !playing){
    playing = true;
    playStartTime = millis();

    updateSpotLight(spotLightPin); // first stop light;
    if(playMillis() > totalPlayTime){
    playStartTime = 0;
    playing = false;

    void updatePulser(int pin){
    float x = playMillis();
    float result = sin(x * (.003 + (x * 0.0000001)))*512;
    if(result > 255){
    result = 255;
    if(result < 0){
    result = 0;

    void updateSpotLight(int pin){
    float result = 255 * (playPercent());

    float playMillis () {
    if (playStartTime == 0){
    return 0;
    return (millis() – playStartTime);

    boolean motionActive(){
    modetectVal = digitalRead(modetectPin);
    if (modetectVal == HIGH) {
    return true;
    else {
    return false;

    float playPercent(){
    return playMillis()/totalPlayTime;


    Is it bad that I call MP3Player.beginTrack(1); inside a loop that’s going to call multiple times? I never had trouble with it before, but maybe that’s gumming things up?



    Your pulseLightPin is the same as the SD_SEL, for the SdCard’s Chip Select. Instead change pulseLightPin to A5.

    I think you mean; MP3player.playTrack(1) (vs beginTrack). playTrack has a safe guard to be an ignore if a file is already playing.

    The “If you get this error…” can only occur during the MP3Player.begin(). And that should only be once. I don’t see another instances. This was a work-a-round warning to make sure the sd.begin was done. It really simply indicates that the SdCard was found but was not started correctly.

    So if you really get this after it starts playing and not at boot. It means the unit rebooted. There is no code reason for that. So there may be some hardware thing. likely miss wired. Not sure if your symptoms are accurately portrayed.

    I suspect it play’s for a bit then the pulseLightPin = 9, messes with the SdCard. Then it memory crashes, reboots, but the SdCard is messed up and prints the above error.

    Otherwise… is this a stock shield? which board and which shield.


    This is the stock Sparkfun MP3 shield VS1063, and I’m using it with an Arduino UNO. I switched the pin from 9 to A5, which worked, but I have to write PWM to these pins, and I think the analog pins can’t do that (or can’t do that as easily.) When I try to connect the lights to pins 11-13, they don’t get the right data passed to them. Is there a reason I can’t use these pins?

    On the upside, the MP3 player works now!


    I’ve isolated the problem, I think, which has to do with which pins are available for PWM on the mp3 shield, vs. which ones are available on the arduino. Other than pin 10, are there any OTHER PWM pins on the mp3 shield?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.