1#include "SoftwareSerial.h"
2#include "DFRobotDFPlayerMini.h"
3
4
5static const uint8_t PIN_MP3_TX = 2;
6static const uint8_t PIN_MP3_RX = 3;
7SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
8
9
10
11
12DFRobotDFPlayerMini player;
13
14void setup() {
15
16pinMode(wirePin, INPUT);
17pinMode(endPin, INPUT);
18
19
20 Serial.begin(9600);
21
22 softwareSerial.begin(9600);
23
24
25 if (player.begin(softwareSerial)) {
26 Serial.println("OK");
27
28
29 player.volume(30);
30
31 player.play(1);
32 } else {
33 Serial.println("Connecting to DFPlayer Mini failed!");
34 }
35}
36
37void loop() {
38
39
40 }
41
PaulVdB
2 years ago
Hi Muhammad_Munir, Your program works fine, but it plays only a few songs. Is there a way to play song-after-song without interruption ? I read the "BUSY" pin on the MP3 shield with (A7) to see if the song is playing or not, it works, but after a few songs it stops playing... here is the sketch I use : void loop() { if (digitalRead(A7) == LOW) { a = random(1,299); Serial.print("playing : a = "); Serial.println(a); execute_CMD(0x03, 0, a); delay(1000); } Thanks in advance !