Play wav Files from Selected folders with push buttons

What Update ?
Where's the DFRobot mp3 player?
Where's your effort?

This Pause next prev available on net . . .
Bit complex coding

#include "SoftwareSerial.h"
SoftwareSerial mySerial(10, 11);
# define Start_Byte 0x7E
# define Version_Byte 0xFF
# define Command_Length 0x06
# define End_Byte 0xEF
# define Acknowledge 0x00 //Returns info with command 0x41 [0x01: info, 0x00: no info]

# define ACTIVATED LOW

int buttonPause = 2;
int buttonPrevious = 3;
int buttonNext = 4;

boolean isPlaying = false;



void setup () {

pinMode(buttonPause, INPUT);
digitalWrite(buttonPause,HIGH);
pinMode(buttonNext, INPUT);
digitalWrite(buttonNext,HIGH);
pinMode(buttonPrevious, INPUT);
digitalWrite(buttonPrevious,HIGH);

mySerial.begin (9600);
delay(1000);
playFirst();
isPlaying = true;


}



void loop () { 

 if (digitalRead(buttonPause) == ACTIVATED)
  {
    if(isPlaying)
    {
      pause();
      isPlaying = false;
    }else
    {
      isPlaying = true;
      play();
    }
  }


 if (digitalRead(buttonNext) == ACTIVATED)
  {
    if(isPlaying)
    {
      playNext();
    }
  }

   if (digitalRead(buttonPrevious) == ACTIVATED)
  {
    if(isPlaying)
    {
      playPrevious();
    }
  }
}

void playFirst()
{
  execute_CMD(0x3F, 0, 0);
  delay(500);
  setVolume(20);
  delay(500);
  execute_CMD(0x11,0,1); 
  delay(500);
}

void pause()
{
  execute_CMD(0x0E,0,0);
  delay(500);
}

void play()
{
  execute_CMD(0x0D,0,1); 
  delay(500);
}

void playNext()
{
  execute_CMD(0x01,0,1);
  delay(500);
}

void playPrevious()
{
  execute_CMD(0x02,0,1);
  delay(500);
}

void setVolume(int volume)
{
  execute_CMD(0x06, 0, volume); // Set the volume (0x00~0x30)
  delay(2000);
}

void execute_CMD(byte CMD, byte Par1, byte Par2)
// Excecute the command and parameters
{
// Calculate the checksum (2 bytes)
word checksum = -(Version_Byte + Command_Length + CMD + Acknowledge + Par1 + Par2);
// Build the command line
byte Command_line[10] = { Start_Byte, Version_Byte, Command_Length, CMD, Acknowledge,
Par1, Par2, highByte(checksum), lowByte(checksum), End_Byte};
//Send the command line to the module
for (byte k=0; k<10; k++)
{
mySerial.write( Command_line[k]);
}
}

Just got this link and anyhow manage to write down code from the running clip

Its with analog input but code is showing errors




#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include "BigButton.h"

SoftwareSerial mySerial(10, 11);

DFRobotDFPlayerMini player;


void setup() 

{


  Serial.begin(9600);
  softwareSerial.begin(9600);
  if(player.begin(softwareSerial))

  {
    Serial.printIn("OK");
   }

   else

    {
    Serial.printIn("FAIL!");
   }

    player.volume(30);

}

void loop() {

              processButton(bigGreenButton, "green", 7, 30);
              processButton(bigRedButton, "red", 5, 30);
 

            }

            int trackPlaying = -1;




void processButton(BigButton & bigButton, char * txt, int trackNo, int intVolume)

      {

        switch (bigButton.checkButton())

        {
            case BUTTON_UP:

            Serial.print(txt);
            Serial.printIn(" up");
            break;

            case BUTTON_UP_DOWN:

            Serial.print(txt);
            Serial.print(player.available());
            Serial.printIn(" mid down");
            break;

            case BUTTON_DOWN:

            Serial.print(txt);
            Serial.printIn(" down");

            if (trackPlaying != trackNo)
            {
              player.volume(intVolume);
              player.play(trackNo);
              trackPlaying = trackNo;  
            }

            else

            {
              
              player.stop();
              
            }
        }
        }
        
      
            

WE HAVE TO MAKE IT FOR DIGITAL INPUTS AND WITH REASONABLE THINGS WITHIN CODE

PLEASE CHECK THE SCRIPT AS I AM NOT SURE IF I HAVE NOTED IT DOWN CORRECTLY VIA FRAMES OF THE CLIP

When attempting a new thing, I always begin at the beginning.
I try to master a concept, make sense of one thing and then I move on.

Start small, work your way Up.

Press a button → Play a track.

Ya exactly i used to do so . . . That's why i used to apply the code @43 by modifying it for a single track play with single push button but here for this

void processButton its showing errors . .

suppose i go this way



#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include "BigButton.h"

SoftwareSerial mySerial(10, 11);

DFRobotDFPlayerMini player;


void setup() 

{


  Serial.begin(9600);
  softwareSerial.begin(9600);
  if(player.begin(softwareSerial))

  {
    Serial.printIn("OK");
   }

   else

    {
    Serial.printIn("FAIL!");
   }

    player.volume(30);

}

void loop() {

              processButton(bigGreenButton, "green", 7, 30);
            
 

            }

            int trackPlaying = -1;




void processButton(BigButton & bigButton, char * txt, int trackNo, int intVolume)

      {

        switch (bigButton.checkButton())

        {
            case BUTTON_UP:

            Serial.print(txt);
            Serial.printIn(" up");
            break;

            

            else

            {
              
              player.stop();
              
            }
        }
        }

Then also i am getting errors at the points where i am not able to understand the issues

And too i am not getting anything like such examples of single track play viz push button other than that you tube example . . . But trying for some other way to find any related article

please help me in getting that

Why do you (Why would anybody) need a thing like bigbutton.h ?

No idea what he did . . . I got it on you tube link i shared @43

Here the simplest code i designed from all the collections till now & it's getting uploaded with no errors but unable to function anything there

#include "SoftwareSerial.h"
SoftwareSerial mySerial(10, 11);
#include "DFRobotDFPlayerMini.h"
# define Start_Byte 0x7E
# define Version_Byte 0xFF
# define Command_Length 0x06
# define End_Byte 0xEF
# define Acknowledge 0x00


int buttonPlay = 2;
//int buttonPause = 3;
//int buttonPrevious = 4;

DFRobotDFPlayerMini player;

void setup () {

pinMode(buttonPlay, INPUT);

mySerial.begin (9600);

}

void loop () { 

 if (digitalRead(buttonPlay) == LOW)
  {
    
      player.play("Track 3");
    
  }
   
}

Other than this i am not getting anything yet

Trying as per my reach

The tracks on the microSD have to be titled after their scheme.
001.wav, 002.wav, 003.wav
A name (or whatever) can be added after the numbers (001dog.wav, 002car.wav, 003bell.wav).

I see . .

So this time i am on simple list of few mp3 songs so how should i script ?

001songname.mp3 ???

001.wav
In the root, not a folder.

OK So for an mp3 file also we need to make extension as .wav ??

Sorry - right, MP3 (001.mp3).

ok sure le me check

Well, is the code all the way right in rest of the places ?
Please comment if anything left here . .

I am on it right now

No its not working still . . .

What's next step on it ?

Final last code is like this

#include "SoftwareSerial.h"
SoftwareSerial mySerial(10, 11);
#include "DFRobotDFPlayerMini.h"
# define Start_Byte 0x7E
# define Version_Byte 0xFF
# define Command_Length 0x06
# define End_Byte 0xEF
# define Acknowledge 0x00


int buttonPlay = 2;
//int buttonPause = 3;
//int buttonPrevious = 4;

DFRobotDFPlayerMini player;

void setup () {

pinMode(buttonPlay, INPUT);

mySerial.begin (9600);

}

void loop () { 

 if (digitalRead(buttonPlay) == LOW)
  {
    
      player.play("003.mp3");
    
  }
   
}
//#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

void setup()
{
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);   // change to whatever you need/like
  
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //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(10);  //Set volume value. From 0 to 30
  //myDFPlayer.play(1);  //Play the first mp3
}

void loop ()
{
  myDFPlayer.play(1);  //Play the first mp3

  delay(5000);  // assuming your track is short
}

Does this "play" anything at all?
If 'No', note any error messages printed in Serial Monitor.

Its the output of serial monitor

DFRobot DFPlayer Mini Demo
Initializing DFPlayer ... (May take 3~5 seconds)
DFPlayer Mini online.

Yes, and. . .

Nothing else

No change with player related actions