MP3 shield not communicating with branch code

Hello I can get the MP3 shield source code from Bill Porter to work with the device, however whenever I try to get any other code to communicate with it will not play track. This includes the example code that came with bill porters code.

// libraries
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
#include <Bounce2.h> 

/**
 * \breif Macro for the debounced NEXT pin, with pull-up
 */
#define B_NEXT  A0

/**
 * \breif Macro for the debounced STOP pin, with pull-up
 */
#define B_STOP  A1

/**
 * \breif Macro for the debounced PLAY pin, with pull-up
 */
#define B_PLAY  A2

/**
 * \breif Macro for the Debounce Period [milliseconds]
 */
#define BUTTON_DEBOUNCE_PERIOD 20 //ms

/**
 * \brief Object instancing the SdFat library.
 *
 * principal object for handling all SdCard functions.
 */
SdFat sd;

/**
 * \brief Object instancing the SFEMP3Shield library.
 *
 * principal object for handling all the attributes, members and functions for the library.
 */
SFEMP3Shield MP3player;

/**
 * \brief Object instancing the Next Button.
 */
Bounce b_Next  = Bounce();

/**
 * \brief Object instancing the Stop Button library.
 */
Bounce b_Stop  = Bounce();

/**
 * \brief Object instancing the Play Button library.
 */
Bounce b_Play  = Bounce();

/**
 * \brief Index of the current track playing.
 *
 * Value indicates current playing track, used to populate "x" for playing the 
 * filename of "track00x.mp3" for track000.mp3 through track254.mp3
 */
int8_t current_track = 0;

//------------------------------------------------------------------------------
/**
 * \brief Setup the Arduino Chip's feature for our use.
 *
 * After Arduino's kernel has booted initialize basic features for this
 * application, such as Serial port and MP3player objects with .begin.
 */
void setup() {
  Serial.begin(115200);

  pinMode(B_NEXT, INPUT_PULLUP);
  pinMode(B_STOP, INPUT_PULLUP);
  pinMode(B_PLAY, INPUT_PULLUP);

  b_Next.attach(B_NEXT);
  b_Next.interval(BUTTON_DEBOUNCE_PERIOD);
  b_Stop.attach(B_STOP);
  b_Stop.interval(BUTTON_DEBOUNCE_PERIOD);
  b_Play.attach(B_PLAY);
  b_Play.interval(BUTTON_DEBOUNCE_PERIOD);

  if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
  if (!sd.chdir("/")) sd.errorHalt("sd.chdir");

  MP3player.begin();
  MP3player.setVolume(10,10);
  
  Serial.println(F("Looking for Buttons to be depressed..."));
}


//------------------------------------------------------------------------------
/**
 * \brief Main Loop the Arduino Chip
 *
 * This is called at the end of Arduino kernel's main loop before recycling.
 * And is where the user's is executed.
 *
 * \note If the means of refilling is not interrupt based then the
 * MP3player object is serviced with the availaible function.
 */
void loop() {

// Below is only needed if not interrupt driven. Safe to remove if not using.
#if defined(USE_MP3_REFILL_MEANS) \
    && ( (USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer) \
    ||   (USE_MP3_REFILL_MEANS == USE_MP3_Polled)      )

  MP3player.available();
#endif

  if (b_Play.update()) {
    if (b_Play.read() == LOW)	{
      Serial.print(F("B_PLAY pressed, Start Playing Track # "));
      Serial.println(current_track);
      MP3player.playTrack(current_track);
    }
  }

  if (b_Stop.update()) {
    if (b_Stop.read() == LOW)	{
      Serial.print(F("B_STOP pressed, Stopping Track #"));
      Serial.println(current_track);
      MP3player.stopTrack();
    }
  }

  if (b_Next.update()) {
    if (b_Next.read() == LOW)	{
      Serial.print(F("B_NEXT pressed, Start Playing Next Track #"));
      Serial.println(++current_track);
      MP3player.stopTrack();
      MP3player.playTrack(current_track);
    }
  }

   //Do something. Have fun with it.

}

I don't understand your problem. The thread title says "MP3 shield not communicating with branch code". What "branch code" is it supposes to communicate with?

The code you posted does something, even if it just prints to the Serial Monitor application. What does it do?

There REALLY is no reason to be using a library to manage switch states.

PaulS:
There REALLY is no reason to be using a library to manage switch states.

At the same time though there's really no reason to change the example code you are given with a library if your aim is to test the hardware. Stick with the code that the author of the library says works, at least until you have the thing working and then you can write more sensible code yourself. Start making changes to the examples just because someone else did something dumb and suddenly you don't know if it doesn't work because of your crappy code or theirs.

It is supposed to play a song when you hit the button. However the MP3player.playTrack(current_track); command isn’t responding.
Delta I haven’t changed the code at all. I have been using their code. It is the developers code. This isn’t the only code that isn’t working though. No other branch code is working for the same reason.

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

SdFat sd;
SFEMP3Shield MP3player;

void setup() {

  Serial.begin(9600);

  //start the shield
  sd.begin(SD_SEL, SPI_HALF_SPEED);
  MP3player.begin();

  //start playing track 1
  MP3player.playTrack(1);
}

//do something else now
void loop() {

  Serial.println("I'm bored!");
  delay(2000);

}

by branch code I mean the codes I have posted, the source code would be sfemp3shield that is #included in both codes

If MP3player.playTrack(1); does not result in track 1 being played, adding more code is NOT going to make the hardware start working. You have a hardware problem.

playTrack will return an error code. Why don't you save and print that error code and see if it gives a clue?

there is no error code that pops up

In none of the code you have shown so far have you even tried to display it.

int errorCode = MP3Player.playTrack(1);

Serial.print("The error code is : ");
Serial.println(errorCode);

no error code comes up unless I hit the next button I have hooked up then it displays error 2 which is saying the desired file is not found. But I have the songs loaded on the micro sd and it is read when it is played from the file player code

Thanks Delta for your help. the problem ended up being that my sd card automatically puts .mp3 at the end of the track names so when I was naming it track001.mp3 it was putting in the system track001.mp3.mp3. Even though it would still work for file player it wouldn't work for any branch code