Thanks for all your help, it works so far. Now I can go further.
I have changed the order of some lines and tried and changed and renamed some more thing and now I can control the Mp3 player through my phone. I am getting somewhere.
I have put my code below for anyone who is interested.
// Arduino D3 to BT RX through a voltage divider
// Arduino D2 BT TX (no need voltage divider)
// Arduino D11 to dfRobot RX
// Arduino D10 to dfRobot TX
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
SoftwareSerial Mp3com(10,11); //RX, TX, communicate with Mp3 player
SoftwareSerial btcom(2,3); //RX, TX, communicate with bluetooth
DFRobotDFPlayerMini Mp3speler; //name Mp3 player
char command; // command variable from bluetooth
void setup(){
Mp3com.begin(9600); //set Mp3 Player baudrate
btcom.begin(9600); //set bluetooth baudrate
Mp3speler.begin(Mp3com); //Use Mp3com to communicate with mp3.
Mp3speler.volume(30);
}
void loop(){
btcom.listen();
if(btcom.available() > 0){
command = btcom.read();
speler();
}
}
void speler(){ //function to control Mp3 player
switch(command){
case 'a':
Mp3speler.start();
break;
case 'b':
Mp3speler.stop();
break;
case 'c':
Mp3speler.next();
break;
case 'd':
Mp3speler.previous();
break;
case 'e':
Mp3speler.volumeDown();
break;
case 'f':
Mp3speler.volumeUp();
break;
}
}