Advertisement
pleasedontcode

**Audio Playback** rev_01

May 1st, 2025
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Audio Playback**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-05-01 07:16:55
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* enabling a obsidian esp32 board and pirate audio */
  21.     /* hat */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <SoftwareSerial.h> //https://github.com/plerup/espsoftwareserial
  28. #include <DFRobotDFPlayerMini.h> //https://github.com/DFRobot/DFRobotDFPlayerMini
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF Software Serial *****/
  35. const uint8_t myDFPlayer_DFPlayerMini_Serial_PIN_SERIAL_TX_D4 = 4;
  36. const uint8_t myDFPlayer_DFPlayerMini_Serial_PIN_SERIAL_RX_D13 = 13;
  37. EspSoftwareSerial::UART myDFPlayer_DFPlayerMini_Serial;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. // Instantiate the DFPlayer Mini object
  41. DFRobotDFPlayerMini myDFPlayer;
  42.  
  43. void setup(void)
  44. {
  45.     // put your setup code here, to run once:
  46.  
  47.     // Initialize Software Serial
  48.     myDFPlayer_DFPlayerMini_Serial.begin(9600, SWSERIAL_8N1, myDFPlayer_DFPlayerMini_Serial_PIN_SERIAL_RX_D13, myDFPlayer_DFPlayerMini_Serial_PIN_SERIAL_TX_D4, false);
  49.  
  50.     // Initialize DFPlayer Mini
  51.     myDFPlayer.begin(myDFPlayer_DFPlayerMini_Serial);
  52.     myDFPlayer.volume(10); // Set volume level (0-30)
  53. }
  54.  
  55. void loop(void)
  56. {
  57.     // put your main code here, to run repeatedly:
  58.     // Example: Play a track
  59.     myDFPlayer.play(1); // Play the first track
  60.     delay(1000); // Wait for 1 second before playing again
  61. }
  62.  
  63. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement