Good evening!
I am currently working on a project which is playing specific sound tracks from the DFPlayer PRO when a specific word is received by the HC-05 module, but I`m facing a problem, altough every thing is working properly including the HC-05 Bluetooth module, the arduino,the code, the DFPlayet Pro and the 0.5W mono speaker, there is no sound (NOTE: When electricity is connected to the speaker it keeps repeating the Word "Music" so I think there is no problem in the speaker) So could you asisst?
I am using a
- Arduino UNO
- A 0.5W mono speaker
- Jumper WIRES
- Resistor
5)HC-05 BT module
6)A breadboard
7)DFPlayer pro without SD card
And this is the codeπ
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
// SoftwareSerial for DFPlayer & HC-05
SoftwareSerial DFSerial(10, 11); // RX, TX (DFPlayer)
SoftwareSerial BTSerial(2, 3); // RX, TX (HC-05)
DFRobotDFPlayerMini DFPlayer;
// Track assignments
const int TRACK_EGYPT = 1; // "Egypt" β 0001.mp3
const int TRACK_SCIENCE = 2; // "Science" β 0002.mp3
const int TRACK_FILM = 3; // "Film" β 0003.mp3
const int TRACK_QUARAN = 4; // "Quaran" β 0004.mp3
void setup() {
Serial.begin(9600);
BTSerial.begin(9600); // HC-05 default baud rate
DFSerial.begin(9600); // DFPlayer default baud rate
// Initialize DFPlayer
if (!DFPlayer.begin(DFSerial)) {
Serial.println("DFPlayer Pro not connected!");
while (true);
}
DFPlayer.volume(20); // Set volume (0-30)
Serial.println("Ready! Say 'Egypt', 'Science', 'Film', or 'Quaran'...");
}
void loop() {
if (BTSerial.available()) {
String command = BTSerial.readStringUntil('\n'); // Read Bluetooth data
command.trim(); // Remove whitespace
// Debug: Print received command
Serial.print("Received: ");
Serial.println(command);
// Check for keywords and play corresponding track
if (command.equalsIgnoreCase("Egypt")) {
DFPlayer.play(TRACK_EGYPT);
Serial.println("Playing: Egypt (Track 1)");
}
else if (command.equalsIgnoreCase("Science")) {
DFPlayer.play(TRACK_SCIENCE);
Serial.println("Playing: Science (Track 2)");
}
else if (command.equalsIgnoreCase("Film")) {
DFPlayer.play(TRACK_FILM);
Serial.println("Playing: Film (Track 3)");
}
else if (command.equalsIgnoreCase("Quaran")) {
DFPlayer.play(TRACK_QUARAN);
Serial.println("Playing: Quaran (Track 4)");
}
}
}



