Power_Broker:
I'm having a real hard time understanding what you're trying to say here. That being said, you might be able to fix the problem by using the class member functionmyMP3.isPlaying()
to determine if a song is being played.
Im sorry if you hard to understand my bad english , therofore, Im grateful to you that you still willing to help me. i will clarify again what is my problem. so, I have project to make line follower with mp3. I have already made a robot line follower before, but its my first time using mp3 series. so, i want my robot would play some musics in some conditions. like, the robot will play song number track 1 if the robot is moving. and play song number 2 if the robot is stop
Power_Broker:
For example, the following code will play all of track 1 and then immediately play track 2. However, note that track 2 will loop:#include <SoftwareSerial.h>
#include <DFPlayerMini_Fast.h>
SoftwareSerial mySerial(10, 11); // RX, TX
DFPlayerMini_Fast myMP3;
void setup()
{
Serial.begin(115200);
mySerial.begin(9600);
myMP3.begin(mySerial);
myMP3.volume(30);
delay(20);
myMP3.play(1);
}
void loop()
{
if(!myMP3.isPlaying())
myMP3.play(2);
}
i have followed your code and change a few , but it just still play song number 1 and cannot switch to the song number 2, even the line sensor has detected. could you give me some sugestions more? here is my code :
#include <SoftwareSerial.h>
#include <DFPlayerMini_Fast.h>
DFPlayerMini_Fast myMP3;
#define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module
#define ARDUINO_TX 6//connect to RX of the module
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);//init the serial protocol, tell to myserial wich pins are TX and RX
void setup()
{
Serial.begin(115200);
mySerial.begin(9600);
myMP3.begin(mySerial);
myMP3.volume(30);
delay(20);
myMP3.play(1);
}
void loop()
{
Serial.print(analogRead(A0) );
Serial.println();
if(analogRead(A0) > 300 )// robot stops
{
if(!myMP3.isPlaying()){
myMP3.play(2);
}
}
}