Devices & Components
Arduino Uno Rev3
3watt speaker
Df player mini
Bread board
Jumper wires (generic)
Project description
Code
Code
arduino
1#include "SoftwareSerial.h" 2#include "DFRobotDFPlayerMini.h" 3 4// 5 Use pins 2 and 3 to communicate with DFPlayer Mini 6static const uint8_t PIN_MP3_TX 7 = 2; // Connects to module's RX 8static const uint8_t PIN_MP3_RX = 3; // Connects 9 to module's TX 10SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX); 11 12// 13 Create the Player object 14DFRobotDFPlayerMini player; 15 16void setup() { 17 18 19 // Init USB serial port for debugging 20 Serial.begin(9600); 21 // Init serial 22 port for DFPlayer Mini 23 softwareSerial.begin(9600); 24 25 // Start communication 26 with DFPlayer Mini 27 if (player.begin(softwareSerial)) { 28 Serial.println("OK"); 29 30 31 // Set volume to maximum (0 to 30). 32 player.volume(30); 33 // Play 34 the first MP3 file on the SD card 35 player.play(1); 36 } else { 37 Serial.println("Connecting 38 to DFPlayer Mini failed!"); 39 } 40} 41 42void loop() { 43}
Code
arduino
1#include "SoftwareSerial.h" 2#include "DFRobotDFPlayerMini.h" 3 4// Use pins 2 and 3 to communicate with DFPlayer Mini 5static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX 6static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX 7SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX); 8 9// Create the Player object 10DFRobotDFPlayerMini player; 11 12void setup() { 13 14 // Init USB serial port for debugging 15 Serial.begin(9600); 16 // Init serial port for DFPlayer Mini 17 softwareSerial.begin(9600); 18 19 // Start communication with DFPlayer Mini 20 if (player.begin(softwareSerial)) { 21 Serial.println("OK"); 22 23 // Set volume to maximum (0 to 30). 24 player.volume(30); 25 // Play the first MP3 file on the SD card 26 player.play(1); 27 } else { 28 Serial.println("Connecting to DFPlayer Mini failed!"); 29 } 30} 31 32void loop() { 33}
Downloadable files
dfplayermini_connect_MMBC2nJ6K8.jpg
dfplayermini_connect_MMBC2nJ6K8.jpg

Comments
Only logged in users can leave comments