极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12033|回复: 2

求教按键控制sd卡播放音乐

[复制链接]
发表于 2015-5-6 19:01:05 | 显示全部楼层 |阅读模式
按照网上的教程学习播放sd卡的音乐 我想加一个按键控制 但是不行 请问一下 代码哪里不对  跪求
#include <SimpleSDAudio.h>  
int inPin=7;
void setup()
{
  pinMode(inPin,INPUT_PULLUP);
  // 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("GHSY.AFM")) {
    while(digitalRead(inPin)==HIGH); // Error file not found -> stop.
  }   
  
  // Start playback
  SdPlay.play();
  
  // Let the worker work until playback is finished
  while(digitalRead(inPin)==HIGH) {
    SdPlay.worker();
  }
}


void loop(void) {
}
回复

使用道具 举报

发表于 2015-5-7 13:20:12 | 显示全部楼层
setup里面只执行一次的把
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-5-8 19:51:38 | 显示全部楼层
连菜鸟都算不上 发表于 2015-5-7 13:20
setup里面只执行一次的把

现在按键不起作用啊 不按按键 还是一直播放音乐
回复 支持 反对

使用道具 举报

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

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-9 11:25 , Processed in 0.067469 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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