Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed DFPlayerMini
Diff: main.cpp
- Revision:
- 0:6b1d260f2b98
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jun 27 05:54:51 2021 +0000
@@ -0,0 +1,39 @@
+/*2021/06/27
+DFplayerを動作させるサンプルプログラム
+仕様:nucleo f401REを使用し、青いボタンを押したら、次の曲が流れる。
+ 曲が停止している間は、mbedについているLEDを点灯し、曲が流れている間はLEDが点滅する。
+
+使用ポート:
+ 青ボタン:PC_13
+ UART RX:PA_10
+ UART TX:PA9
+ LED点灯、点滅:LED1
+*/
+
+#include "mbed.h"
+#include "DFPlayerMini.h"
+
+DigitalOut myled(LED1); //LED
+DigitalIn sw(PC_13); //再生ボタン
+
+DFPlayerMini mp3(PA_9,PA_10); //TX:PA_9(D8) RX:PA_10(D2)
+DigitalIn busy(PB_3); //DFPlayerMiniのBUSYと接続する
+
+int main() {
+ while(1)
+ {
+ if(sw == 0){ //青ボタンを押すと次の曲を再生
+ mp3.mp3_next(); //0001.mp3を再生
+ wait(0.1);
+ }
+ if (busy == 1 ){ //再生停止している場合は、LED点灯
+ myled = 1;
+ }else if( busy == 0 ) //再生中は、lEDを点滅させる
+ {
+ wait(0.1);
+ //LEDを点滅させる
+ myled = !myled;
+ wait(0.2);
+ }
+ }
+}