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() {
keypad.addEventListener(keypadEvent);
Serial.begin(9600);
//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");
MP3player.begin();
}
void loop() {
keypad.getKey();
MP3player.available();
}
void keypadEvent(KeypadEvent eKey) {
switch (keypad.getState()) {
case PRESSED:
;
Serial.println(eKey);
switch (eKey) {
case '#': //PLAY
Filename.concat(".mp3");
Serial.println(Filename);
MP3player.playMP3(Filename);
break;
case '*': //RESET
Filename.concat(".mp3");
Serial.println(Filename);
break;
default: //DEFAULT
Filename.concat(eKey);
}
}
}