Sparkfun mp3 trigger and arduino

Hi. I use the Sparkfun Mp3 trigger with arduino bord. I have hook it up correctly and it works just fine.
But the code have a "Delay" code and will only play certain amount of seconds of the tracks. What I want is to play one track and when is finished, the next track will play. I have a 10 minute long track i ŵant to play and at the same time i want commands to turn on and off some lights.

// function test: mp3-trigger test with Arduino UNO
//
// connections UNO --- mp3trigger
// 0 RX --- TX
// 1 TX --- RX
// GND --- GND

void setup(){
Serial.begin(38400); // standard for mp3trigger
}

void loop()
{
// play track 1. name on sd-card: 001.mp3
Serial.print("t");
Serial.write(1);
delay(5000);

// play track 5. name on sd-card: 005.mp3
Serial.print("t");
Serial.write(5);
delay(5000);

// play track 77. name on sd-card: 077.mp3
Serial.print("t");
Serial.write(77);
delay(5000);

// play track 121. name on sd-card: 121.mp3
Serial.print("t");
Serial.write(121);
delay(5000);

}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

What did you think the delay(5000); was going to do for your code? Based on your description, I can't think of any reason to have it there.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.