In the same spirit, please don't post an image of the serial monitor instead of the serial monitor output itself, which is text, like code and error messages are One good reason is that an image of text is probably a thousand times as much data as the text itself.
Posting images of things which are not essentially text is fine.
Serial.print("Player 1 file number = ");
Serial.println(player_1_fileNumber);
Player_1_lastPlayed = player_1_fileNumber;
Serial.println("attempting to play player 1");
Mp3Player1.play(player_1_fileNumber);
int x = digitalRead(BusyPin_1); // added for testing
Serial.print("the int x = "); // added for testing
Serial.println(x);
while (x == 1) {
x = digitalRead(BusyPin_1);
}
Here is the serial monitor's output after adding the prints. Since I don't think you want to see ten seconds of "Player1 loop delay
Player2 loop delay"
I trimmed it
Starting Player 1
Player 1 Online
Starting Player 2
Player 2 Online
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player 1 file number = 11
attempting to play player 1
After that test, I made the Busy Pins INPUT_PULLUP
void setup() {
Serial.begin(9600);
pinMode(BusyPin_1, INPUT_PULLUP); // PIN 12 ON NANO
pinMode(BusyPin_2, INPUT_PULLUP); // PIN 13 ON NANO
startPlayer_1();
startPlayer_2();
}
And again, it stops when trying to play
Starting Player 1
Player 1 Online
Starting Player 2
Player 2 Online
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player 1 file number = 8
attempting to play player 1
Serial.print("Player 1 file number = ");
Serial.println(player_1_fileNumber);
Player_1_lastPlayed = player_1_fileNumber;
Serial.println("attempting to play player 1");
MySerial_1.listen();
Mp3Player1.play(player_1_fileNumber);
int x = digitalRead(BusyPin_1);
Serial.print("the int x = ");
Serial.println(x);
while (x == 1) {
x = digitalRead(BusyPin_1);
}
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player 1 file number = 12
attempting to play player 1
Only the other day, someone was asking for help with their project and that involved 2x BH1750 light sensors. Turned out to be a bug in the library, because when they tried an alternative library, it worked.
There are bugs in the latest version of the DFRobotDFPlayerMini library. I resolved obscure problems a year or so ago by reverting from version 1.0.7 to 1.0.6 which I've used since then. Worth a try.
Mp3Player1.setTimeOut(500); // Set Serial communictaion time out 500ms
Mp3Player1.volume(30); // Set volume value (0~30).
delay(1000);
Mp3Player1.EQ(DFPLAYER_EQ_BASS); // Set EQ to BASS (normal/pop/rock/jazz/classic/bass)
Mp3Player1.outputDevice(DFPLAYER_DEVICE_SD); // Set device we use SD as default
Mp3Player1.enableDAC();
Serial.println("Player 1 Online");
Mp3Player2.setTimeOut(500); // Set Serial communictaion time out 500ms
Mp3Player2.volume(30); // Set volume value (0~30).
delay(1000);
Mp3Player2.EQ(DFPLAYER_EQ_BASS); // Set EQ to BASS (normal/pop/rock/jazz/classic/bass)
Mp3Player2.outputDevice(DFPLAYER_DEVICE_SD); // Set device we use SD as default
Mp3Player2.enableDAC();
Serial.println("Player 2 Online");
Added the suggested delay
Starting Player 1
Player 1 Online
Starting Player 2
Player 2 Online
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player1 loop delay
Player2 loop delay
Player 1 file number = 4
attempting to play player 1
The sketch did not get past this part of the code " Serial.println("attempting to play player 1")"
Serial.print("Player 1 file number = ");
Serial.println(player_1_fileNumber);
Player_1_lastPlayed = player_1_fileNumber;
Serial.println("attempting to play player 1");
Mp3Player1.play(player_1_fileNumber);
int x = digitalRead(BusyPin_1);
Serial.print("the int x = ");
Serial.println(x);
The files play just fine in other of the players I have made, as well as the project that has two players if I start just that one player. That was explained in my original post.
Yes, that is the test I want to make. When the difference between the current millis and previous millis is greater or equal to an unsigned long called delayLoop that is set to 10000 (ten seconds) in this test code. In the final project, that delayLoop will be a random value that I have not picked yet.
Declared above, the setup(){}
unsigned long player_1_loopDelay = 0;
unsigned long player_1_PreviousMillis;
within the Player_1_delayLoop() the player_1_PreviousMillis is set to the current millis only if the player_1_loopDelay equals 0 followed by the player_1_loopDelay being set to 10000.
if (player_1_loopDelay == 0) {
player_1_PreviousMillis = millis();
player_1_loopDelay = 10000;
}
unsigned long player_1_CurrentMillis = millis();
if (player_1_CurrentMillis - player_1_PreviousMillis >= player_1_loopDelay) {
randomSeed(analogRead(0));
player_1_fileNumber = random(1, 13);
At the end of the file playing, the player_1_loopDelay is set to zero at line 78