Hello everybody,
I tried creating an arduino Nano ATmega328p project where I can play MP3 files on a speaker attached to a DFPlayer Mini.
#include "DFRobotDFPlayerMini.h"
#include <SoftwareSerial.h>
const int soundSerialRx = 10; // RX des DFPlayer Mini
const int soundSerialTx = 11; // TX des DFPlayer Mini
const int ledPin1 = 2; // LED 1
const int ledPin2 = 3; // LED 2
const int buttonPin = 4; // Taster
SoftwareSerial soundSerial(soundSerialRx, soundSerialTx);
DFRobotDFPlayerMini soundPlayer;
unsigned long startTime = 0;
bool isPlaying = false;
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
soundSerial.begin(9600);
soundPlayer.begin(soundSerial);
soundPlayer.volume(30);
}
void loop() {
if (digitalRead(buttonPin) == LOW && !isPlaying) {
soundPlayer.playMp3Folder(1);
for (int i = 0; i < 20; i++) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
delay(50);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(50);
}
startTime = millis();
isPlaying = true;
}
if (isPlaying && (millis() - startTime >= 5000)) {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
isPlaying = false;
}
if (digitalRead(buttonPin) == HIGH && isPlaying) {
isPlaying = false;
}
}
I attached the Pin11 of Arduino to TX and Pin10 to RX.
The folder on my SD-Card (16gb, formatted in fat32) is called "mp3" and the file inside 0001.mp3
The arduino gets power, but in the serial Monitor i only get the errors:
18:57:33.367 -> DFRobot DFPlayer Mini Demo
18:57:33.367 -> Initializing DFPlayer ... (May take 3~5 seconds)
18:57:33.367 -> ~⸮Unable to begin:
18:57:35.595 -> 1.Please recheck the connection!
18:57:35.595 -> 2.Please insert the SD card!
The attached speaker is a "Mini speaker 40mm 8 Ohm 0.5W"
The LEDs are functioning as expected, but can be ignored for the sake of this question.
Why do i not get audio output?