I'm having a problem with the player - it does not play music over Arduino (it starts the music as standalone, when connect his GND pin to ADKEY_1).
My Wiring is next:
- 5VDC power supply just for mp3 player
- second GND pin from mp3 wired to GND of Arduino
- RX pin wired to pin 10 on Arduino over 1k resistor
- TX pin wired to pin 11 (tried to swap these two)
- SPK_1 and SPK_2 wired to the speaker
This is my code: (please ignore commended parts of the code, for start, I just want to play the first file when it is powered).
Red led on the player is always on, and his BUSY pin gives me "0" when I'm reading it (pin 24 on Arduino side) - like it is playing all the time...
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
static const uint8_t PIN_MP3_TX = 10; // Rx na modulu
static const uint8_t PIN_MP3_RX = 11; // TX na modulu
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX); // kreiranje serijske komunikacije za plejer
int pirSenzor = 13;
int stanjePlayera = 24;
DFRobotDFPlayerMini player; // kreiranje player objekta
void setup() {
pinMode(pirSenzor, INPUT);
pinMode(stanjePlayera, INPUT); // očitavanje da li se audio fajl reprodukuje ili ne (LOW = u toku je reprodukcija)
Serial.begin(115200); // serijska komunikacija za monitoring
softwareSerial.begin(9600); // serijska komunikacija za plejer
if (player.begin(softwareSerial)) {
Serial.println("Konekcija sa plejerom uspešna!");
player.volume(30); // jačina zvuka je u opsegu od 0-30
} else {
Serial.println("Proveri komunikaciju sa plejerom i prisutnost sd kartice!");
}
}
void loop() {
int pirStanje = digitalRead(pirSenzor);
int playerStanje = digitalRead (stanjePlayera);
// Serial.println (pirStanje);
Serial.println (playerStanje);
// if (pirStanje == HIGH && playerStanje == HIGH) { // pusti reprodukciju kada pir senzor detektuje pokret, ali samo ako fajl već nije u fazi reprodukcije
// (sprečavanje prekidanja zvuka iznova)
player.play(1);//} // pusti prvi fajl na kartici
}
All connections checked 10 times, I have two more players and always is the same and one more Mega and everything is the same...
EDIT: It plays sound one time, every time while uploading this code above...