Guest User

Untitled

a guest
Apr 11th, 2020
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.85 KB | None | 0 0
  1. /*******************************************************************************
  2.  * DFPlayer_Mini_Mp3, This library provides a quite complete function for      *
  3.  * DFPlayer mini mp3 module.                                                   *
  4.  * www.github.com/dfrobot/DFPlayer_Mini_Mp3 (github as default source provider)*
  5.  *  DFRobot-A great source for opensource hardware and robot.                  *
  6.  *                                                                             *
  7.  * This file is part of the DFplayer_Mini_Mp3 library.                         *
  8.  *                                                                             *
  9.  * DFPlayer_Mini_Mp3 is free software: you can redistribute it and/or          *
  10.  * modify it under the terms of the GNU Lesser General Public License as       *
  11.  * published by the Free Software Foundation, either version 3 of              *
  12.  * the License, or any later version.                                          *
  13.  *                                                                             *
  14.  * DFPlayer_Mini_Mp3 is distributed in the hope that it will be useful,        *
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
  17.  * GNU Lesser General Public License for more details.                         *
  18.  *                                                                             *
  19.  * DFPlayer_Mini_Mp3 is distributed in the hope that it will be useful,        *
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
  22.  * GNU Lesser General Public License for more details.                         *
  23.  *                                                                             *
  24.  * You should have received a copy of the GNU Lesser General Public            *
  25.  * License along with DFPlayer_Mini_Mp3. If not, see                           *
  26.  * <http://www.gnu.org/licenses/>.                                             *
  27.  *                                         *
  28.  ******************************************************************************/
  29.  
  30. /*
  31.  *  Copyright:  DFRobot
  32.  *  name:       DFPlayer_Mini_Mp3 sample code
  33.  *  Author:     lisper <[email protected]>
  34.  *  Date:       2014-05-30
  35.  *  Description:    connect DFPlayer Mini by SoftwareSerial, this code is test on Uno
  36.  *          Note: the mp3 files must put into mp3 folder in your tf card
  37.  */
  38. #include <SoftwareSerial.h>
  39. #include <DFPlayer_Mini_Mp3.h>
  40. #include <IRremote.h>
  41. int RECV_PIN = 12;
  42. SoftwareSerial mySerial(9, 10); // RX, TX
  43. #define code1  16582903
  44. #define code2  16615543
  45. IRrecv irrecv(RECV_PIN);
  46. decode_results results;
  47.  
  48. //
  49. void setup () {
  50.     Serial.begin (9600);
  51.     mySerial.begin (9600);
  52.     mp3_set_serial (mySerial);  //set softwareSerial for DFPlayer-mini mp3 module
  53.     delay(1);  //wait 1ms for mp3 module to set volume
  54.     mp3_set_volume (15);
  55.   irrecv.enableIRIn();  // Start the receiver
  56. }
  57.  
  58.  
  59. //
  60.  
  61. void loop () {        
  62.      if (irrecv.decode(&results)) {
  63.     unsigned int value = results.value;
  64.     switch(value) {
  65.     case code1:
  66.     mp3_play (3);
  67.     delay (100000);
  68.     break;
  69.  
  70. case code2:
  71. mp3_play (1);
  72.   break;
  73. /*
  74.    mp3_play ();     //start play
  75.    mp3_play (5);    //play "mp3/0005.mp3"
  76.    mp3_next ();     //play next
  77.    mp3_prev ();     //play previous
  78.    mp3_set_volume (uint16_t volume);    //0~30
  79.    mp3_set_EQ ();   //0~5
  80.    mp3_pause ();
  81.    mp3_stop ();
  82.    void mp3_get_state ();   //send get state command
  83.    void mp3_get_volume ();
  84.    void mp3_get_u_sum ();
  85.    void mp3_get_tf_sum ();
  86.    void mp3_get_flash_sum ();
  87.    void mp3_get_tf_current ();
  88.    void mp3_get_u_current ();
  89.    void mp3_get_flash_current ();
  90.    void mp3_single_loop (boolean state);    //set single loop
  91.    void mp3_DAC (boolean state);
  92.    void mp3_random_play ();
  93.  */}
  94.      }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment