Hi !
Here, I am having a code for simple song play with a trigger input, but it's not able to detect the the folder in which the songs are present.
DF Player is getting serial accessed by Arduino's common controlled configuration we all have.
Code is here :
#include <SoftwareSerial.h>
#include <DFMiniMp3.h>
#include "DFRobotDFPlayerMini.h"
const byte IN1 = 2;
const int OUT1 = 5;
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
byte pbRegister = 0;
void setup()
{
mySoftwareSerial.begin(9600);
Serial.begin(9600); // change to whatever you need/like
if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
myDFPlayer.volume(29); //Set volume value. From 0 to 30
pinMode (IN1, INPUT_PULLUP);
pinMode (OUT1, OUTPUT);
}
void loop()
{
do
{
if (!digitalRead(IN1))
{
pbRegister = 1;
}
}while (pbRegister == 0);
switch(pbRegister)
{
case 1:
Serial.println("Track 001");
myDFPlayer.playMp3Folder(1);
break;
}
pbRegister = 0;
delay(250); // "debounce"
}
In the above script, I have here this line
myDFPlayer.playMp3Folder(1);
which should simply detect the folder to play but it's not working
Please Help . . . Thanks !!!
What is the folder called?
DFPlayer is quite confusing. From what I can see, playMP3Folder(1) is looking for a file 0001.mp3 under a root folder called MP3.
Maybe loopFolder or playFolder are worth a look.
It is
myDFPlayer.playFolder(1,1); // (folder, file) folder 1, file 1
I see !! That's mark-able . .
Would you please let me have a script in single line to add in my code ??
O Yessss !!! Its working fully here . . .
I just added and checked
Thanks for the help sir . . I am a step ahead here !!
Is it possible to make some action of shuffling folders with this kind of command with code?
int (folderbutton) = 3;
What is the real question ?
Well that's a case for later to discuss
I am having very very small issue with a defined output for (indicator purpose)
For this code below :
switch(pbRegister)
{
case 1:
Serial.println("Track 001");
//myDFPlayer.play(1); //Playing file Out of Folder
myDFPlayer.playFolder(2,1); // Playing file inside a Folder
break;
}
It's working the way we need . . .
Number of times i press the switch , it triggers sound with a very small delay after the press !!
But when it comes to add a small script for indication purpose to let the LED glow approx equal to the length of the song as here below :
switch(pbRegister)
{
case 1:
Serial.println("Track 001");
//myDFPlayer.play(1); //Playing file Out of Folder
myDFPlayer.playFolder(2,1); // Playing file inside a Folder
digitalWrite(OUT1, HIGH);
delay(21450); // Lenght of the song
digitalWrite(OUT1, LOW);
delay(0);
break;
}
Once it gets triggered with push button, then i am unable to make it trigger again in between the played song, until and unless the OUTPUT of LED becomes low or say the song stops playing as per delay length i applied.
I keep pressing repeatedly but no effect on anything unlike that old Sd card module designs
I have to wait . .
The DFplayer has a Busy pin that you can use.
Why not use the DFplayer's LED (if this is really about an LED)?
Ya actually the reason here is connected to multi inputs with multi outputs as personal indicator
An example of what i want to have in final take is here . . please check
Ya one thing i can do here
Busy pin can be routed to each output with AND Gate per output indicating module . .
Sir i am not getting a proper script other than this for busy pin
const byte pinDfpBusy = 12;
On basis of collections
i arranged it further like this
if (digitalRead(pinDfpBusy) == HIGH)
{ delay(1);
digitalWrite(OUT1, HIGH);
}
if (digitalRead(pinDfpBusy) == LOW)
{ delay(1);
digitalWrite(OUT1, LOW);
}
But its getting the LED continuously glowing after the input gets triggered and no change with the file getting stopped from playing !!!
I don't know exactly how you're implementing this into 'The Whole'.
Here's my 'thought' --
If you start a Play you can ("safely") turn your BusyMonitor LED On.
From that point, poll the Busy pin and wait for it to go Off, where you would turn the
BusyMonitor LED Off.
#include <SoftwareSerial.h>
#include <DFMiniMp3.h>
#include "DFRobotDFPlayerMini.h"
const byte IN1 = 3;
const int OUT1 = 5;
const byte pinDfpBusy = 12;
//int (folderbutton) = 4;
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
byte pbRegister = 0;
void setup()
{
mySoftwareSerial.begin(9600);
Serial.begin(9600); // change to whatever you need/like
if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
myDFPlayer.volume(29); //Set volume value. From 0 to 30
pinMode (IN1, INPUT_PULLUP);
pinMode (OUT1, OUTPUT);
}
void loop()
{
do
{
if (!digitalRead(IN1))
{
pbRegister = 1;
}
}while (pbRegister == 0);
if (digitalRead(pinDfpBusy) == HIGH)
{ delay(1);
digitalWrite(OUT1, HIGH);
}
if (digitalRead(pinDfpBusy) == LOW)
{ delay(1);
digitalWrite(OUT1, LOW);
}
switch(pbRegister)
{
case 1:
Serial.println("Track 001");
//myDFPlayer.play(1); //Playing file Out of Folder
myDFPlayer.playFolder(2,1); // Playing file inside a Folder
//digitalWrite(OUT1, HIGH);
//delay(21450); // Lenght of the song
//digitalWrite(OUT1, LOW);
//delay(0);
break;
}
pbRegister = 0;
delay(100); // "debounce"
}