Created
April 1, 2025 13:28
-
-
Save rahulbot/00380828bef10a306fd9a6c17dd0779e to your computer and use it in GitHub Desktop.
Simple debug console for DFRobot DFPlayer Pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <DFRobot_DF1201S.h> | |
| #include <SoftwareSerial.h> | |
| SoftwareSerial DF1201SSerial(2, 3); //RX TX | |
| DFRobot_DF1201S DF1201S; | |
| void setup(void){ | |
| Serial.begin(115200); | |
| Serial.println("Initialize MP3 player"); | |
| DF1201SSerial.begin(115200); | |
| while(!DF1201S.begin(DF1201SSerial)){ | |
| Serial.println("Init failed, please check the wire connection!"); | |
| delay(1000); | |
| } | |
| // Set and confirm volume | |
| DF1201S.setVol(10); | |
| Serial.print(" Volume: "); | |
| Serial.println(DF1201S.getVol()); | |
| // Enter "Music Mode" - for playing files | |
| DF1201S.switchFunction(DF1201S.MUSIC); | |
| delay(500); // wait for end of prompt | |
| // set and confirm to play just one file | |
| DF1201S.setPlayMode(DF1201S.SINGLE); | |
| Serial.print(" PlayMode: "); /*Get playback mode*/ | |
| Serial.println(DF1201S.getPlayMode()); | |
| // how many files? | |
| Serial.print(" Files: "); | |
| Serial.println(DF1201S.getTotalFile()); | |
| } | |
| void loop() { | |
| DF1201S.playFileNum(1); | |
| delay(4000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment