Devices & Components
Arduino Nano
Bread Board
1k Resistor
Jumper wire
Df Player Mini
Speaker
Project description
Code
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 10 11// Create the Player object 12DFRobotDFPlayerMini player; 13 14void setup() { 15 16pinMode(wirePin, INPUT); 17pinMode(endPin, INPUT); 18 19 // Init USB serial port for debugging 20 Serial.begin(9600); 21 // Init serial port for DFPlayer Mini 22 softwareSerial.begin(9600); 23 24 // Start communication with DFPlayer Mini 25 if (player.begin(softwareSerial)) { 26 Serial.println("OK"); 27 28 // Set volume to maximum (0 to 30). 29 player.volume(30); 30 // Play the first MP3 file on the SD card 31 player.play(1); 32 } else { 33 Serial.println("Connecting to DFPlayer Mini failed!"); 34 } 35} 36 37void loop() { 38 39 40 } 41
Comments
Only logged in users can leave comments