Reference

Last revision 2025/12/19

The article offers a comprehensive guide on managing audio playback via AD buttons and AT command protocols, detailing button functions, resistor configurations, and precise command usage for volume control, playback modes, and LED prompts.

AD Button Controlling

Control by Button

  1. Tap the PLAY button to play or pause(Blue LED keeps on when playing and blinks slowly when pausing).
  2. Long-press the for 2 seconds to switch to the next song(Blue LED blinks twice when switching).

Get AD Button from DFRobot Store or DFRobot Distributor.

Key Resistor in Series Click Long-press
K0 0R Pause & Play
K1 3K Last Volume +
K2 6.2K Next Volume -
K3 9.1K Switch Play Mode
K4 15K Fast Forward 10s
K5 24K Pause & Play Next
K6 33K Volume - Volume -
K7 51K Volume + Volume +
K8 100K Fast Rewind 10s
K9 220K Play the first song, set volume to 10

DFR0768ADKEY

Communication Protocol Description

AT Command Controlling

Note:

  1. "\r\n is" omitted in all the commands below, and you need to add it to the end of the command in actual use. For example "AT+VOL=5\r\n", designate volume to "5".
  2. Default serial baud rate: 115200
/**
 * @brief Test Connection
 */
AT  //Test Connection

/**
 * @brief Set/Query Volume(Volume:0-30)(Power-down save) 
 * @param -n:Volume -n
 *        +n:Volume +n
 *         n:Designate volume to n
 *         ?:Query volume
 */
AT+VOL=-5  //Volume -5

AT+VOL=?   //Query volume
return:VOL = [10]   //The current volume is 10

/**
 * @brief Control playback mode
 * @param  1:repeat one song
 *         2:repeat all
 *         3:play one song and pause
 *         4:Play randomly
 *         5:Repeat all in the folder
 *         ?:query the current playback mode
 */
AT+PLAYMODE=1   //Switch to repeat-one-song mode 

AT+PLAYMODE=?   //Query current playback mode 
Return:PLAYMODE =1  //Current playback mode: repeat one song

/**
 * @brief Control playing
 * @param    PP:Play & Pause
 *         NEXT:next
 *         LAST:last
 */
AT+PLAY=NEXT   //last

/**
 * @brief Playing time control 
 * @param -n:Fast Rewind n S
 *        +n:Fast Forward n S
 *         n:Start playing from the Nth second
 */
AT+TIME=-5   //Fast Rewind 5S

/**
 * @brief Query playback information 
 * @param  1:Query the file number of the currently-playing file
 *         2:Query the total number of the files
 *         3:Query the time length the song has played
 *         4:Query the total time of the currently-playing file
 *         5:Query the file name of the currently-playing file
 */
AT+QUERY=1   //Query the file number of the currently-playing file

AT+QUERY=5  //Query the file name of the currently-playing file
Return:test.mp3    //The currently-playing file is "test.mp3"


/**
 * @brief Play the file of the specified number 
 * @param        n:File number(Play the first file if there is no such file)
 */
AT+PLAYNUM=5                       //Play file No. 5 

/**
 * @brief Play the specific file
 * @param File path
 */
AT+PLAYFILE=/DF_REC/test.MP3        //Play the test.mp3 under DF_REC once 

/**
 * @brief Amplifier On/OFF command
 * @param    ON, OFF
 */
AT+AMP=ON   //Turn on amplifier 

/**
 * @brief Delete currently-playing file
 */
AT+DEL

/**
 * @brief Set baud rate (power-down save, valid after re-powering on)
 * @param    9600、19200、38400、57600、115200
 */
AT+BAUDRATE=115200  //Set baud rate to 115200

/**
 * @brief Prompt tone ON/OFF command (Power-down save)
 * @param    ON, OFF
 */
AT+PROMPT=ON   //Turn on prompt tone 

//LED Prompt On/Off Command(Power-down save) 
/**
 * @brief LED Prompt ON/OFF command (Power-down save)
 * @param    ON, OFF
 */
AT+LED=ON   //Turn on LED Prompt 

API Description

  • Main API Function List
  /**
   * @brief Set volume 
   * @param vol:0-30
   * @return true or false
   */
  bool setVol(uint8_t vol);
  
  /**
   * @brief Set playback mode 
   * @param ePlayMode_t:SINGLECYCLE,ALLCYCLE,SINGLE,RANDOM,FOLDER
   * @return true or false
   */
  bool setPlayMode(ePlayMode_t mode);
  
  /**
   * @brief Play 
   * @return true or false
   */
  bool start();
  
  /**
   * @brief Pause 
   * @return true or false
   */
  bool pause();
  
  /**
   * @brief Next 
   * @return true or false
   */
  bool next();
  
  /**
   * @brief Previous 
   * @return true or false
   */
  bool last();
  
  /**
   * @brief Fast forward the currently-playing song
   * @param second  FF time(Unit: S) 
   */
  bool fastForward(uint16_t second);
  
  /**
   * @brief Fast Rewind the currently-playing song 
   * @param second  FR time(Unit: S)
   */
  bool fastReverse(uint16_t second);
  
  /**
   * @brief Let the currently-playing song start playing from a particular point of the audio file 
   * @param second  Fixed time point
   */
  bool setPlayTime(uint16_t second);
  
  /**
   * @brief Get file number 
   */
  uint16_t getCurFileNumber();
  
  /**
   * @brief Get the number of files available to play 
   */
  uint16_t getTotalFile();
  
  /**
   * @brief Get the time length the current song has played 
   */
  uint16_t getCurTime();
  
  /**
   * @brief Get the total length of the currently-playing song
   */
  uint16_t getTotalTime();
  
  /**
   * @brief Get the name of the playing file 
   */
  String   getFileName();
  
  /**
   * @brief Play file of the specific path 
   * @param The designated path 
   */
  bool playSpecFile(String str);
  
  /**
   * @brief Play the file of specific number, the numbers are arranged according to the sequences the files copied into the U-disk 
   * @param File number, can be obtained by getCurFileNumber()
   */
  bool playFileNum(int16_t num);
  
  /**
   * @brief Delete the currently-playing file 
   * @return true or false
   */
  bool delCurFile();

Was this article helpful?

TOP