【发布时间】:2019-02-05 14:58:08
【问题描述】:
我想用 Arduino nano、迷你 dfplayer mp3 和 3 个按钮(下一个、上一个、暂停/恢复)制作一个 mp3 播放器。
我找到了建立连接的数据表并尝试了这个:
电源将是一个 5V 1A 的移动电源,但为了测试,我使用的是插入电脑的 USB。
代码:
#include <SoftwareSerial.h>
#include <DFPlayerMini_Fast.h>
SoftwareSerial mySerial(10, 11); // RX, TX
DFPlayerMini_Fast myDFPlayer;
void setup()
{
Serial.begin(115200);
mySerial.begin(9600);
myDFPlayer.begin(mySerial);
}
void loop()
{
myDFPlayer.play(1); //play mp3 file with leading identifier "0001"
myDFPlayer.volume(1); //set volume low
delay(100); //wait 100ms
myDFPlayer.volume(30); //crank that stuff!
delay(100); //wait another 100ms
while(1); //halt
}
问题:
所以我的问题是我可以毫无错误地上传代码,并且 mp3 模块的灯是启用的,但是当我连接扬声器断开连接时,我听到来自 windows 10 的声音。
声音就像没有信号的旧电视。
零件:
- Arduino 纳米
- 迷你dfplayer mp3 https://www.dfrobot.com/product-1121.html
- sd 卡 4Gb
- 喇叭4Ω 3W https://sites.google.com/a/u.depdatoc.com/a231/-2pcs-lot-4-ohm-3W-3Watts-50MM-Speaker-18MM-Internal-Magnetic-Foam-Edge-Surround-Silvery
注意:
我给了你一个没有使用任何按钮的代码,因为这不是我的问题,我会处理。
Rx,Tx 电阻为 1kΩ。
按键电阻为10KΩ
是的,我已将 sd 卡格式化为 fat32,我在根目录下有一个名为 mp3 的文件夹,里面有 5 个 mp3 文件 0001,0002,0003 等。
扬声器没有焊接,所以我只是连接电线(模块的扬声器1和扬声器2)看看它是否工作。
扬声器以前工作过。
图书馆: https://github.com/PowerBroker2/DFPlayerMini_Fast
如果你还想问我!
【问题讨论】:
-
重置 Arduino 通常表示硬件问题,这里不谈。如果一个空的草图导致同样的问题,那么这不是一个编程问题。
-
@gre_gor 我不认为 Arduino 有问题,因为我曾尝试单独使用扬声器和按钮,但效果很好。
标签: arduino mp3 arduino-ide