Advertisement
kartonman

DF Player Mini Play 1 song

Sep 28th, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /* dfPlayer Mini Play 1 song From Project Hub
  2. at https://create.arduino.cc/projecthub/munir03125344286/play-audio-in-arduino-dde2e2
  3. */
  4.  
  5.  
  6.  
  7. #include "SoftwareSerial.h"
  8. #include "DFRobotDFPlayerMini.h"
  9.  
  10. // Use pins 2 and 3 to communicate with DFPlayer Mini
  11. static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX
  12. static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX
  13. SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
  14.  
  15. // Create the Player object
  16. DFRobotDFPlayerMini player;
  17.  
  18. void setup() {
  19.  
  20. // Init USB serial port for debugging
  21. Serial.begin(9600);
  22. // Init serial port for DFPlayer Mini
  23. softwareSerial.begin(9600);
  24.  
  25. // Start communication with DFPlayer Mini
  26. if (player.begin(softwareSerial)) {
  27. Serial.println("OK");
  28.  
  29. // Set volume to maximum (0 to 30).
  30. player.volume(30);
  31. // Play the first MP3 file on the SD card
  32. player.play(1);
  33. } else {
  34. Serial.println("Connecting to DFPlayer Mini failed!");
  35. }
  36. }
  37.  
  38. void loop() {
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement