

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

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX


DFRobotDFPlayerMini myDFPlayer;


byte octet=0;
byte octet0=512;
int enr1=0;
int son=0;
int ma=1;
int dt=0;
long t0=millis();
int enr=0;
int lect=0;
int n=0;
int dt2;
long t2=millis();
int ce=0;
int cl=0;
int p=1;
int csy=0;
int cr=0;
int cf=0;
int vr;
long t1=millis();
int cv=0;
int ck=0;







void setup()
{
 
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(13,OUTPUT);
   
  mySoftwareSerial.begin(9600);
  Serial.begin(9600);
 
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  
  if (!myDFPlayer.begin(mySoftwareSerial,false)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true){
      delay(0); // Code to compatible with ESP8266 watch dog.
    }
  }
  Serial.println(F("DFPlayer Mini online."));
  
  myDFPlayer.volume(25);  //Set volume value. From 0 to 30

  
}

void loop()
{


 if (Serial.available() > 0)
          {
           
              octet = Serial.read();
              Serial.println(octet);

if (octet==49) myDFPlayer.play(1);
if (octet==50) myDFPlayer.play(2);
if (octet==51) myDFPlayer.play(3);
if (octet==52) myDFPlayer.play(4);
if (octet==53) myDFPlayer.play(5);
if (octet==54) myDFPlayer.play(6);
if (octet==55) myDFPlayer.play(7);
if (octet==56) myDFPlayer.play(8);

           
             
            }




 
}
