MP3 shield IR problem or syntax, assistance appreciated.

Dear experts,

I was trying to use IR with Sparkfun MP3 shiled, for the purpose I used the example available in the sparkfun library by the name of "MP3ButtonPlayer2". The remote O am using is by ketes, I have decoded all the keys through IR library. However, when I compile and upload the code to arduino I dont get anything on the serial monitor except for the message "Looking for Buttons to be depressed...". If I upload the un modified code it does play mp3 tracks without any problem. I was just wondering is there something wrong with the code or is there a syntax problem sensor and Arduino work otherwise, I am a relative newbie to coding. Code is as follows:

/**
 * \file MP3ButtonPlayer2.ino
 *
 * \brief Example sketch of using the MP3Shield Arduino driver using buttons,
 * with arduino recommended(simpler) debounce library
 * \remarks comments are implemented with Doxygen Markdown format
 *
 * \author Michael P. Flaga
 *
 * This sketch demonstrates the use of digital input pins used as buttons as 
 * NEXT, PLAY and STOP to control the tracks that are to be played.
 * Where PLAY or STOP will begin or cancel the stream of track000.mp3 through 
 * track999.mp3, as indexed by NEXT, begining with 0.

 * \note Use this example uses the bounce2 library to provide debouncing fuctions. Advocated by Arduino's website at http://playground.arduino.cc/code/bounce
 */

// libraries
#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
#include <Bounce2.h> 
#include "IRremote.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
 */
int receiver = 4; // Signal Pin of IR receiver to Arduino Digital Pin 6
int8_t current_track = 0;
IRrecv irrecv(receiver);    // create instance of 'irrecv'
decode_results results;     // create instance of 'decode_results'
//------------------------------------------------------------------------------
/**
 * \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);
  irrecv.enableIRIn(); // Start the receiver
  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
   //Do something. Have fun with it.
   if (irrecv.decode(&results)) // have we received an IR signal?
{
  {
      if (results.value == 0xFF629D) 
        Serial.print(F("B_PLAY pressed, Start Playing Track # "));
        MP3player.playTrack(current_track);
        delay(2000); 
           
   
    } if (results.value == 0xFFC23D) {
      Serial.print(F("B_STOP pressed, Stopping Track #"));
      Serial.println(current_track);
      MP3player.stopTrack();
      delay(2000); 
    } if (results.value == 0xFF02FD) {

      Serial.print(F("B_NEXT pressed, Start Playing Next Track #"));
      Serial.println(++current_track);
      MP3player.stopTrack();
      (++current_track);
      MP3player.playTrack(current_track);
      delay(2000); 
   
  }
}
 irrecv.resume(); // receive the next value
}

I was just wondering is there something wrong with the code or is there a syntax problem

If there was a syntax problem, you wouldn't have gotten to the upload step. Since you talking about running the code, clearly there were no syntax problems.

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
   //Do something. Have fun with it.
   if (irrecv.decode(&results)) // have we received an IR signal?
{
  {
      if (results.value == 0xFF629D)

Curly braces have { their uses, but { randomly splattering { them in the code is NOT a good idea.

Inconsistent placement of curly braces is NOT a good idea, either.

Put EVERY { on a line BY ITSELF.
Put EVERY } on a line BY ITSELF.
Use Tools + Auto Format to fix the indenting.

If you are not seeing anything on the serial monitor, it would seem to mean that you are not getting anything from the remote that matches what you expect.

With your current code, you have no way of knowing whether the problem is that what you got is not what you expect or if you didn't get anything. One more Serial.print() statement will clear that up.

If you are not getting anything, then it is possible that the MP3 player is using some resource (a timer, most likely) that the IR receiver needs.

Don't expect us to hunt for the device you are using to play MP3. Post a link to it.

If you are using the remote in place of physical switches, why did you not remove the code that sets up the physical switches (and the class that deals with them)?

Put the code back that actually reads those switches, and reconnect them if needed. Do they still function - as in making the MP3 player play music?

Actually with a slight variation (earlier code) does work although it is limited in its uses but it does work to an extent, the code is as follows:

/**
 * \file MP3ButtonPlayer2.ino
 *
 * \brief Example sketch of using the MP3Shield Arduino driver using buttons,
 * with arduino recommended(simpler) debounce library
 * \remarks comments are implemented with Doxygen Markdown format
 *
 * \author Michael P. Flaga
 *
 * This sketch demonstrates the use of digital input pins used as buttons as 
 * NEXT, PLAY and STOP to control the tracks that are to be played.
 * Where PLAY or STOP will begin or cancel the stream of track000.mp3 through 
 * track999.mp3, as indexed by NEXT, begining with 0.

 * \note Use this example uses the bounce2 library to provide debouncing fuctions. Advocated by Arduino's website at http://playground.arduino.cc/code/bounce
 */

// libraries
#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
#include <Bounce2.h> 
#include "IRremote.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
 */
int receiver = 4; // Signal Pin of IR receiver to Arduino Digital Pin 6
int8_t current_track = 0;
IRrecv irrecv(receiver);    // create instance of 'irrecv'
decode_results results;     // create instance of 'decode_results'
//------------------------------------------------------------------------------
/**
 * \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);
  irrecv.enableIRIn(); // Start the receiver
  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
   //Do something. Have fun with it.
   if (irrecv.decode(&results)) // have we received an IR signal?

  {
    switch(results.value)

    {

      case 0xFFC23D: // Next button pressed
                      Serial.print(F("B_PLAY pressed, Start Playing Track # "));
                      Serial.println(++current_track);
                      MP3player.playTrack(current_track);
                      delay(2000); 
                      break;

      case 0xFF02FD: // Menu button pressed
                      Serial.print(F("B_STOP pressed, Stopping Track #"));
                      Serial.println(current_track);
                      MP3player.stopTrack();
                      delay(2000); 
                      break;
      case 0xFFA857: // Down button pressed
                      Serial.print(F("B_NEXT pressed, Start Playing Next Track #"));
                      Serial.println(++current_track);
                      MP3player.stopTrack();
                      (++current_track);
                      MP3player.playTrack(current_track);
                      delay(2000); 
                      break;                
    }
    
      irrecv.resume(); // receive the next value
  }

}

Just want to know and fix why this one works and other doesn't?

link to the remote:
Remote Link

and link to the mp3 board:
MP Shield

In the code that doesn't "work" (for some undefined definition of work), you have this, after putting all the curly braces on their own lines and properly indenting:

  //Do something. Have fun with it.
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    {
      if (results.value == 0xFF629D)
        Serial.print(F("B_PLAY pressed, Start Playing Track # "));
      MP3player.playTrack(current_track);
      delay(2000);     
    }

Clearly, that curly brace on the third line is not useful. If the if statement evaluates to true, you will get serial output. Regardless of whether the if statement is true or not, you pla a track and then delay(). I doubt that that was your intention.

Perhaps now you can see why I harp about useless curly braces and curly braces being placed at the end of statements. Way too hard to see what lines up with what that way, or to spot missing braces/extra braces.

Paul, Thanks modified the code as you suggested, but still nothing:

void setup() {
  Serial.begin(115200);
  irrecv.enableIRIn(); // Start the receiver
  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
  //Do something. Have fun with it.
  if (irrecv.decode(&results)) // have we received an IR signal?
  {

    if (results.value == 0xFF629D)
    MP3player.playTrack(current_track);
      Serial.print(F("B_PLAY pressed, Start Playing Track # "));
    
    //  delay(2000);


    if (results.value == 0xFFC23D) {
      MP3player.stopTrack();
      Serial.print(F("B_STOP pressed, Stopping Track #"));
      Serial.println(current_track);
      
      //delay(2000);
    } if (results.value == 0xFF02FD) {
      MP3player.stopTrack();
      (++current_track);
      MP3player.playTrack(current_track);
      Serial.print(F("B_NEXT pressed, Start Playing Next Track #"));
      Serial.println(++current_track);

      // delay(2000);

    }
  }
  irrecv.resume(); // receive the next value
}

Paul, Thanks modified the code as you suggested

No, you didn't.

Put EVERY { on a line BY ITSELF.
Put EVERY } on a line BY ITSELF.
Use Tools + Auto Format to fix the indenting.

I did revise the code but still it doesnt go beyond the message, I mean I am not asking for a hand holding but any help in the right direction would be appreciated, thanks for the "pau"l:

"
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
  //Do something. Have fun with it.
  if (irrecv.decode(&results)) // have we received an IR signal?
  {

    if (results.value == 0xFF629D)
      MP3player.playTrack(current_track);
    Serial.print(F("B_PLAY pressed, Start Playing Track # "));

    //  delay(2000);


    if (results.value == 0xFFC23D)
    {
      MP3player.stopTrack();
      Serial.print(F("B_STOP pressed, Stopping Track #"));
      Serial.println(current_track);

      //delay(2000);
    }
    if (results.value == 0xFF02FD)
    {
      MP3player.stopTrack();
      (++current_track);
      MP3player.playTrack(current_track);
      Serial.print(F("B_NEXT pressed, Start Playing Next Track #"));
      Serial.println(++current_track);

      // delay(2000);

    }
  }
  irrecv.resume(); // receive the next value
}
  if (irrecv.decode(&results)) // have we received an IR signal?
  {

    if (results.value == 0xFF629D)
      MP3player.playTrack(current_track);
    Serial.print(F("B_PLAY pressed, Start Playing Track # "));

    if (results.value == 0xFFC23D)
    {
      MP3player.stopTrack();
      Serial.print(F("B_STOP pressed, Stopping Track #"));
      Serial.println(current_track);

      //delay(2000);
    }

If you get some data from the IR, and it that data is 0xFF629D, play some track.

If you get some data from the IR, regardless of what the data is, print a message that says that B_PLAY was pressed.

Does that make sense?

Why not print the data received? Then, you'd have a clue whether or not you were getting data and mishandling it, or not getting data to handle, properly or not.

The IR library uses a timer. Does the MP3 player/class also need that same timer?