Hi everyone,
I'm having issues when trying to get a button to control the MP3 shield with an Arduino Uno.
The button works fine and I can print "on" or "off" to the serial monitor, however as soon as I include "MP3player.begin();" the button pressing will stop working, it will constantly say it is "on" - no matter whether it is actually pressed or not.
Does anyone know why this may be? As soon as I comment out the MP3player.begin(); line it works again?
Here is my full code:
#include <SPI.h>
//Add the SdFat Libraries
#include <SdFat.h>
#include <SdFatUtil.h>
//and the MP3 Shield Library
#include <SFEMP3Shield.h>
SdFat sd;
SFEMP3Shield MP3player;
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int buttonState = LOW;
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
//Initialize the MP3 Player Shield and SD card
sd.begin(SD_SEL, SPI_FULL_SPEED);
// This is the line that is causing the problem
MP3player.begin();
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.println("on");
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
Serial.println("off");
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Any help would be greatly appreciated.
Many thanks,
Ollie