电子说

YX5300/6300串口MP3音乐播放模块集成了 MP3、WAV 的硬解码SOC。 同时软件支持工业级别的串口通信协议,以 SPIFLASH、TF 卡(FAT32/16 32GB以内)或者 U 盘作为存储介质, 用户可以灵活的选用其中的任何一种设备作为语音的存储介质。通过简单的串口指令即可完成播放指定的语音,以及如何播放语音等功能,无需繁琐的底层操作,使用方便。
参数:



| ESP32开发板 | YX5300 |
|---|---|
| 5V | VCC |
| GND | GND |
| 17 | RX |
| 18 | TX |


文件夹的名称必须由两位数字组成,而每首歌曲的名称则必须以三位数字开头。此外,每首歌曲的名称都必须是唯一的。请注意:最多可以创建99个文件夹,每个文件夹中可存放255首歌曲。

Arduino IDE中安装YX5300驱动库,打开示例程序,上传到ESP32开发板中,YX5300插好3.5mm有线耳机或有源音箱3.5mm线。

#include < YX5300_ESP32.h >
// *make sure the RX on the YX5300 goes to the TX on the ESP32, and vice-versa
#define RX 16
#define TX 17
YX5300_ESP32 mp3; // the mp3 object
void setup() {
// initialize connection with the module
mp3 = YX5300_ESP32(Serial2, RX, TX);
// Shows whats being sent to and from the device, with helpful errors
// Serial.begin(115200);
// mp3.enableDebugging();
// Begins playing from 001.mp3/wav and continuously loops through all the songs
// on the SD card ONLY if there is no track already playing or paused.
mp3.resume();
// other ways to begin playing tracks (see documentation for functionality)
// mp3.playTrack(1);
// mp3.playTrackInLoop(1);
// mp3.playFolderInLoop(1);
// mp3.playTrackInFolder(1, 1);
}
void loop() {
// put your main code here, to run repeatedly:
}
通过以上实验,我们了解到YX5300串口MP3音乐播放模块在ESP32中的简单应用,当然也可以直接与USB转TTL串口模块接好线,串口助手软件发送相关控制指令,对MicroSD卡中的音乐文件进行播放控制。
审核编辑 黄宇
全部0条评论
快来发表一下你的评论吧 !