user50552: I have an MP3 shield on a Arduino Uno. When using "File Player" I can get the tracks to play by keyboard entry with three digits (001-009).
The problem is that I want to use (SFEMP3Shield > examples > MP3ButtonPlayer2) that is looking for files 1-9. Any file numbers other than 1,2,3,4,5,6,7,8,9 doesn’t work. Any suggestions?

user37622: The playTrack function used in MP3ButtonPlayer2 example plays file with name created with printf format "track%03d.mp3". %03d creates a number prefixed with zeros to lenght 3. For example track005.mp3 or track042.mp3 or track999.mp3.
implementation of the playTrack function:
uint8_t SFEMP3Shield::playTrack(uint8_t trackNo){

  //a storage place for track names
  char trackName[] = "track001.mp3";
  uint8_t trackNumber = 1;

  //tack the number onto the rest of the filename
  sprintf(trackName, "track%03d.mp3", trackNo);

  //play the file
  return playMP3(trackName);
}

change it to:
uint8_t SFEMP3Shield::playTrack(uint8_t trackNo){

  //a storage place for track names
  char trackName[13];
  int trackNumber = trackNo;

  //tack the number onto the rest of the filename
  sprintf(trackName, "track%03d.mp3", trackNumber);

  //play the file
  return playMP3(trackName);
}


50552: <p>I have an MP3 shield on a Arduino Uno. When using "File Player" I can get the tracks to play by keyboard entry with three digits (001-009).</p>

<p>The problem is that I want to use (SFEMP3Shield > examples > MP3ButtonPlayer2) that is looking for files 1-9. Any file numbers other than 1,2,3,4,5,6,7,8,9 doesn’t work. Any suggestions?</p>
 37622: <p>The <code>playTrack</code> function used in MP3ButtonPlayer2 example plays file with name created with printf format "track%03d.mp3". %03d creates a number prefixed with zeros to lenght 3. For example track005.mp3 or track042.mp3 or track999.mp3.</p>

<p>implementation of the playTrack function:</p>

<pre><code>uint8_t SFEMP3Shield::playTrack(uint8_t trackNo){

  //a storage place for track names
  char trackName[] = "track001.mp3";
  uint8_t trackNumber = 1;

  //tack the number onto the rest of the filename
  sprintf(trackName, "track%03d.mp3", trackNo);

  //play the file
  return playMP3(trackName);
}
</code></pre>

<p>change it to:</p>

<pre><code>uint8_t SFEMP3Shield::playTrack(uint8_t trackNo){

  //a storage place for track names
  char trackName[13];
  int trackNumber = trackNo;

  //tack the number onto the rest of the filename
  sprintf(trackName, "track%03d.mp3", trackNumber);

  //play the file
  return playMP3(trackName);
}
</code></pre>
