极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2701|回复: 1

求助,如何让SimpleSdaudio重复播放音乐(已解决)

[复制链接]
发表于 2023-2-6 13:15:30 | 显示全部楼层 |阅读模式
本帖最后由 王安安 于 2023-2-6 17:32 编辑

我照着这个教程做了
https://www.geek-workshop.com/forum.php?mod=viewthread&tid=2611
但是我想要开机自动播放指定音乐,并且能循环播放(不使用串口)
求大神指点

已解决,代码附在下面,里面的File name就是文件名,填你自己的
回复

使用道具 举报

 楼主| 发表于 2023-2-6 17:32:35 | 显示全部楼层
#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) {

}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-28 23:36 , Processed in 0.043175 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表