I want the arduino to play music when a push button sends a LOW signal.
MP3player.playTrack(1);
Why are you telling the device to play the track, in setup()?
if (digitalRead(buttonPin)== HIGH) {
Serial.print(F("track001.mp3"));
Serial.println(current_track);
MP3player.playTrack(current_track);
- Doesn't look like a LOW to me.
- The farting around with "track001.mp3" and printing current_track anonymously do nothing useful.
void playtime() {
startingMillis = millis(); // set both time counter
currentMillis = millis();
while ( currentMillis - startingMillis < playTime ) { // while track plays, runs until playTime is reached
currentMillis = millis(); // set to actual time
delay(40); // debounce
}
}
A big fat delay()!
When I run this I get no faults, but also no music
Then, you need a really simple sketch. What should loop() look like:
void loop()
{
}
That's right. You do NOTHING in loop(). Not a thing. Make setup() play the track. Do not add any more code until you know that the hardware is working.