DFRobot DFPlayer Mini volume() calls dont work?

Hello there,

I am trying to get 9 seperate DFPlayers working on the Arduino Mega.
Unfortunately the volume() calls dont work as intended. I've got a micro switch for each Player with which i want to mute the player when its released.

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial1(25, 26); // RX, TX
DFRobotDFPlayerMini myDFPlayer1;
int sw1 = 27;
SoftwareSerial mySoftwareSerial2(22, 23); // RX, TX
DFRobotDFPlayerMini myDFPlayer2;
int sw2 = 24;

//These Players use Hardware Serial Ports
DFRobotDFPlayerMini myDFPlayer3; //RX/TX 1
int sw3 = 28;
DFRobotDFPlayerMini myDFPlayer4; //RX/TX 2
int sw4 = 29;
DFRobotDFPlayerMini myDFPlayer5; //RX/TX 3
int sw5 = 30;

SoftwareSerial mySoftwareSerial3(2, 3); // RX, TX
DFRobotDFPlayerMini myDFPlayer6;
int sw6 = 4;
SoftwareSerial mySoftwareSerial4(5, 6); // RX, TX
DFRobotDFPlayerMini myDFPlayer7;
int sw7 = 7;
SoftwareSerial mySoftwareSerial5(8, 9); // RX, TX
DFRobotDFPlayerMini myDFPlayer8;
int sw8 = 10;
SoftwareSerial mySoftwareSerial6(11, 12); // RX, TX
DFRobotDFPlayerMini myDFPlayer9;
int sw9 = 13;

boolean player1_muted = true;
boolean player2_muted = true;
boolean player3_muted = true;
boolean player4_muted = true;
boolean player5_muted = true;
boolean player6_muted = true;
boolean player7_muted = true;
boolean player8_muted = true;
boolean player9_muted = true;

void setup()
{
  mySoftwareSerial1.begin(9600);
  mySoftwareSerial2.begin(9600);
  mySoftwareSerial3.begin(9600);
  mySoftwareSerial4.begin(9600);
  mySoftwareSerial5.begin(9600);
  mySoftwareSerial6.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
  Serial3.begin(9600);
  Serial.begin(115200);

  myDFPlayer1.begin(mySoftwareSerial1);
  myDFPlayer2.begin(mySoftwareSerial2);
  myDFPlayer3.begin(mySoftwareSerial3);
  myDFPlayer4.begin(mySoftwareSerial4);
  myDFPlayer5.begin(mySoftwareSerial5);
  myDFPlayer6.begin(mySoftwareSerial6);
  myDFPlayer7.begin(Serial1);
  myDFPlayer8.begin(Serial2);
  myDFPlayer9.begin(Serial3);

  myDFPlayer1.loop(1);  //Play the first mp3
  Serial.println("Sound 1 is being played");
  myDFPlayer2.loop(1);  //Play the second mp3
  Serial.println("Sound 2 is being played");
  myDFPlayer3.loop(1);  //Play the third mp3
  Serial.println("Sound 3 is being played");
  myDFPlayer4.loop(1);  //Play the fourth mp3
  Serial.println("Sound 4 is being played");
  myDFPlayer5.loop(1);  //Play the fifth mp3
  Serial.println("Sound 5 is being played");
  myDFPlayer6.loop(1);  //Play the sixth mp3
  Serial.println("Sound 6 is being played");
  myDFPlayer7.loop(1);  //Play the seventh mp3
  Serial.println("Sound 7 is being played");
  myDFPlayer8.loop(1);  //Play the eighth mp3
  Serial.println("Sound 8 is being played");
  myDFPlayer9.loop(1);  //Play the nineth mp3
  Serial.println("Sound 9 is being played");

  pinMode(sw1, INPUT_PULLUP);
  pinMode(sw2, INPUT_PULLUP);
  pinMode(sw3, INPUT_PULLUP);
  pinMode(sw4, INPUT_PULLUP);
  pinMode(sw5, INPUT_PULLUP);
  pinMode(sw6, INPUT_PULLUP);
  pinMode(sw7, INPUT_PULLUP);
  pinMode(sw8, INPUT_PULLUP);
  pinMode(sw9, INPUT_PULLUP);
}

void loop()
{
  /*if (myDFPlayer3.available()) {
    printDetail(myDFPlayer3.readType(), myDFPlayer3.read()); //Print the detail message from DFPlayer to handle different errors and states.
    }*/
boolean sw1State = digitalRead(sw1);
boolean sw2State = digitalRead(sw2);
boolean sw3State = digitalRead(sw3);
boolean sw4State = digitalRead(sw4);
boolean sw5State = digitalRead(sw5);
boolean sw6State = digitalRead(sw6);
boolean sw7State = digitalRead(sw7);
boolean sw8State = digitalRead(sw8);
boolean sw9State = digitalRead(sw9);
  if (sw1State && player1_muted) {
    myDFPlayer1.volume(10);
    player1_muted = false;
  }
  else if (!sw1State && !player1_muted) {
    myDFPlayer1.volume(0);
    player1_muted = true;
  }

  if (sw2State && player2_muted) {
    myDFPlayer2.volume(10);
    player2_muted = false;
  }
  else if (!sw2State && !player2_muted) {
    myDFPlayer2.volume(0);
    player2_muted = true;
  }
  if (sw3State && player3_muted) {
    myDFPlayer3.volume(10);
    player3_muted = false;
  }
  else if (!sw3State && !player3_muted) {
    myDFPlayer3.volume(0);
    player3_muted = true;
  }
  if (sw4State && player4_muted) {
    myDFPlayer4.volume(10);
    player4_muted = false;
  }
  else if (!sw4State && !player4_muted) {
    myDFPlayer4.volume(0);
    player4_muted = true;
  }
  if (sw5State && player5_muted) {
    myDFPlayer5.volume(10);
    player5_muted = false;
  }
  else if (!sw5State && !player5_muted) {
    myDFPlayer5.volume(0);
    player5_muted = true;
  }
  if (sw6State && player6_muted) {
    myDFPlayer6.volume(10);
    player6_muted = false;
  }
  else if (!sw6State && !player6_muted) {
    myDFPlayer6.volume(0);
    player6_muted = true;
  }
  if (sw7State && player7_muted) {
    myDFPlayer7.volume(10);
    player7_muted = false;
  }
  else if (!sw7State && !player7_muted) {
    myDFPlayer7.volume(0);
    player7_muted = true;
  }
  if (sw8State && player8_muted) {
    myDFPlayer8.volume(10);
    player8_muted = false;
  }
  else if (!sw8State && !player8_muted) {
    myDFPlayer8.volume(0);
    player8_muted = true;
  }
  if (sw9State && player9_muted) {
    myDFPlayer9.volume(10);
    player9_muted = false;
  }
  else if (!sw9State && !player9_muted) {
    myDFPlayer9.volume(0);
    player9_muted = true;
  }
}
void printDetail(uint8_t type, int value) {
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerUSBInserted:
      Serial.println("USB Inserted!");
      break;
    case DFPlayerUSBRemoved:
      Serial.println("USB Removed!");
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }

}

That's an impressive number of software serial ports!

I've not used more than 1 myself but reading through the forums, only 1 software serial port can be receiving data at any one time. In the case of your DFPlayer, you may be lucky in that the player only sends data in response to a command from the Arduino.

I would suggest that you configure your system for 1 software serial port and see if that works. Then add in a second software serial port and check that works alongside the first software serial port. Then add the third etc.

thanks for the reply, i will try this!

Okay i have found an issue in my code, it works now!