MP3 Shield VS1053 issues

Hi all,
i’m stuck in my project and can use some help!

I have an arduino uno with a MP3Shield and a keypad connected. I want to use the keypad to enter a 3 digit number, add “.mp3” to it (thats the filename) and then play that specific file on the mp3 shield.
All the demo codes that come with the library work so im sure everything is connected properly. For some reason, in my own code it wont recognise the command ‘MP3player.playMP3(Filename);’ which i got directly from the demo code. What am i missing?

#include "Keypad.h"
#include "Password.h"
#include "SPI.h"
#include "SdFat.h"
#include "FreeStack.h"
#include "SFEMP3Shield.h"

SdFat sd;

SFEMP3Shield MP3player;

String Filename;

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
byte rowPins[ROWS] = { A0, A1, A2, A3};
byte colPins[COLS] = { A4, A5, 0, 5};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Password PasswordA1 = Password( "A18" );

void setup() {

  //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");



void loop() {


void keypadEvent(KeypadEvent eKey) {
  switch (keypad.getState()) {
    case PRESSED:

      switch (eKey) {

        case '#':               //PLAY

        case '*':             //RESET

        default:              //DEFAULT

Hintbox.ino (1.49 KB)

Is this the library you're using:

If so, the playMP3() function takes a pointer to a c-string (aka null-terminated char arrary), not an object of the String class.

hi thanks for your response! that is the library im using indeed.

Im not sure i understand your answer. In other words, any idea how to fix this? I need a way to play a mp3 file by a filename that is entered with a keypad.

You should build the file name in a statically-defined, null-terminated char array rather than a String object. That will serve the dual purpose making the library happy and avoiding the potential issues caused by the String class’s dynamic memory allocation / de-allocation.

A Google search for ‘c-string’ will provide an abundance of information.

As a quick hack, you might try changing the call in your current code to:


But, the long-term stability of your project may suffer.