求助,如何让SimpleSdaudio重复播放音乐(已解决)
本帖最后由 王安安 于 2023-2-6 17:32 编辑我照着这个教程做了
https://www.geek-workshop.com/forum.php?mod=viewthread&tid=2611
但是我想要开机自动播放指定音乐,并且能循环播放(不使用串口)
求大神指点
已解决,代码附在下面,里面的File name就是文件名,填你自己的
#include <SimpleSDAudio.h>
void setup()
{
// If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:
// SdPlay.setSDCSPin(10);
// Init SdPlay and set audio mode
if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO)) {
while(1); // Error while initialization of SD card -> stop.
}
// Select file to play
if(!SdPlay.setFile("File name")) {
while(1); // Error file not found -> stop.
}
// Start playback
SdPlay.play();
// Let the worker work until playback is finished
while(1){
if(!SdPlay.isStopped()){
SdPlay.worker();
}
if(SdPlay.isStopped()){
SdPlay.play();
}
}
}
void loop(void) {
}
页:
[1]