bonjour je reviens vers vous une nouvelle fois pour le code de mon DFPlayer mini
après avoir chercher sur les tutos et sur le net ,même sur chatgpt, je ne trouve pas comment afficher ma piste en cours /
j'ai bien créer le void spécifique pour la lecture de la piste avec son adresse hexa trouver dans le datasheet du DFPLAYER MINI mais je pense que j'ai raté une étape .
ci joint le code
merci d'avance pour votre aide.
[code]
#include "SoftwareSerial.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C Lcd(0x27, 16, 2); // ECRAN LCD 12
//-------------------------------------------------------
SoftwareSerial mySerial(2, 3);//TX RX
#define Start_Byte 0x7E
#define Version_Byte 0xFF
#define Command_Length 0x06
#define Acknowledge 0x00
#define End_Byte 0xEF
#define Acknowledge 0x00
#define ACTIVATED LOW
int BPrevious = 4;
int BPause = 5;
int BPlay = 6;
int BNext = 7;
int val_Previous = 0.0;
int val_Pause = 0.0;
int val_Play = 0.0;
int val_Next = 0.0;
int val_volume = 0.0;
boolean isPlaying = false;
//-------------------------------------------------------------
void setup() {
Serial.begin(115200);
mySerial.begin(9600);
delay(1000);
Lcd.init();
Lcd.backlight(); //PROPRE A CET AFFICHEUR LCD 12C
pinMode(BPrevious, INPUT_PULLUP);
pinMode(BPause, INPUT_PULLUP);
pinMode(BPlay, INPUT_PULLUP);
pinMode(BNext, INPUT_PULLUP);
pinMode(A0, INPUT);
Lcd.setCursor(0, 0);
Lcd.print("PISTE");
Lcd.setCursor(11, 0);
Lcd.print("PLAY");
Lcd.setCursor(0, 1);
Lcd.print("VOLUME");
playFirst();
Serial.println("Pause");
playTrack (1, 1);
Serial.println("Dossier 01, Piste #1");
}
//--------------------------------------------------------------------
void loop() {
//-----------------------------------------------------------------------
val_volume = analogRead(A0);
val_Previous = digitalRead(4);
val_Pause = digitalRead(5);
val_Play = digitalRead(6);
val_Next = digitalRead(7);
int vol_ume = 0.0;
int numpiste = 0.0;
if (val_Previous == LOW) {
playPrevious();
Serial.print("piste precedent ");
Serial.println(val_Previous);
Lcd.setCursor(11, 0);
Lcd.print("precedent");
delay (500);
}
else {
Serial.print("precedent ");
Serial.println(val_Previous);
delay (500);
}
if (val_Pause == LOW) {
Pause();
Serial.print("Pause ");
Serial.println(val_Pause);
Lcd.setCursor(11, 0);
Lcd.print("pause");
delay (500);
}
else {
Serial.print("Pause ");
Serial.println(val_Pause);
delay (500);
}
if (val_Play == LOW) {
Play();
Serial.print("Reprend la lecture ");
Serial.println(val_Play);
Lcd.setCursor(11, 0);
Lcd.print(" play");
delay (500);
}
else {
Serial.print("Reprend la lecture ");
Serial.println(val_Play);
delay (500);
}
if (val_Next == LOW) {
playNext();
Serial.print("Piste Suivante ");
Serial.println(val_Next);
Lcd.setCursor(11, 0);
Lcd.print("suivant");
delay (500);
}
else {
Serial.print("Piste Suivante ");
Serial.println(val_Next);
delay (500);
}
vol_ume = val_volume / 1023 * 30;
Serial.print("volume ");
Serial.println(vol_ume);
Lcd.setCursor(8, 1);
Lcd.print(vol_ume);
delay(500);
Serial.print("piste ");
Serial.println (numpiste);
Lcd.setCursor(8, 0);
Lcd.print(numpiste);
delay(500);
}
//------------------------
void playFirst() {
execute_CMD(0x0F, 1, 1); // Sélectionne la chanson 01 du dossier 01
delay(500);
}
void Pause()
{
execute_CMD(0x0E, 0, 0);
delay(500);
}
//------------------------
void Play() // Reprend après une pause
{
execute_CMD(0x0D, 0, 0);
delay(500);
}
//------------------------
void playNext()
{
execute_CMD(0x01, 0, 0);
delay(500);
}
//------------------------
void playPrevious()
{
execute_CMD(0x02, 0, 0);
delay(500);
}
void setVolume(int vol_ume)
{
execute_CMD(0x06, 0, vol_ume); // Set the volume (0x00~0x30)
delay (500);
}
void numpiste(int numpiste)
{
execute_CMD(0x03, 0, 0); // mum de piste
delay (500);
}
}
//------------------------
void playTrack(byte FloderNo, byte TrackNo)
{
Pause();
execute_CMD(0x0F, FloderNo, TrackNo); // Sélectionne le dossier donné et la piste donnée
delay(500);
}
//------------------------
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 }; //7E FF 06 0D 00 00 01 XX XX EF
//Send the command line to the module
for (byte k = 0; k < 10; k++)
{
mySerial.write(Command_line[k]);
}
}
//--------------------------------------------------------------------------------
/*myMp3.volume(map(analogRead(A0), 0, 1023, 0, 50));
Lcd.setCursor(6, 0);
Lcd.print(myMp3.readCurrentFileNumber());
Lcd.setCursor(7, 1);
if (myMp3.readVolume() < 10) {
Lcd.print(String("0") + myMp3.readVolume());
delay (1000);
}
else {
Lcd.print(myMp3.readVolume());
delay (1000);
}
}
void TrackNumberClear() {
delay(500);
Lcd.setCursor(6, 0);
Lcd.print(" ");
}*/
[/code]