ArduinoTroubleshooting

DFR0745 test for end of file

userHead jlbachiochi 2023-07-19 23:52:21 142 Views1 Replies

If i play all files in a loop…

 

void loop()

{

  for(int i=0; i<=12; i++)

  {

  Serial.println("Playing File # " + String(i));

  df1101s.playSpecFile(i);

   }

  delay(1000);

}

 

the complete file is cut short.  Do i need to know how long each file is and put a delay after the play command?

2023-07-20 10:30:51

Hi!

You can change the mode to play all files in a loop in the setup function.

#include <DFRobot_DF1101S.h>

 

#include <SoftwareSerial.h> SoftwareSerial df1101sSerial(2, 3);  //RX  TX

 

 

DFRobot_DF1101S df1101s;

 

 

void setup(void){  

 

 

Serial.begin(115200);  

 

 

df1101sSerial.begin(115200);  

 

 

while(!df1101s.begin(df1101sSerial))

{    Serial.println("Init failed, please check the wire connection!");    

 

delay(1000);  }  /*Set volume to 20*/  

 

df1101s.setVol(20);  

 

 

Serial.print("VOL:");  /*Get volume*/  

 

 

Serial.println(df1101s.getVol());  /*Enter music mode*/  

 

 

df1101s.switchFunction(df1101s.MUSIC);  /*Wait for the end of prompt tone*/

 

 

delay(2000);  /*Set playback mode to "repeat all"*/  

 

 

df1101s.setPlayMode(df1101s.ALLCYCLE);  

 

}

 

void loop(){  /*Start*/

 

  df1101s.start();  

 

 

delay(3000);

}

userHeadPic jenna