“音乐播放”的版本间的差异
来自Labplus盛思维基百科
Jiangzhaohui(讨论 | 贡献) (创建页面,内容为“=== Arduino示例 === <pre style="color:blue"> #include <SoftwareSerial.h> #include "kt540b.h" uint8_t inBuff[3] = { 0 }; uint8_t inByte; Kt540bClass mp3Play(5, 6);…”) |
Tangliufeng(讨论 | 贡献) |
||
第1行: | 第1行: | ||
− | === Arduino示例 === | + | [[文件:黑色传感器最终版12.20-24.png|350px|缩略图|右]] |
+ | == 概述 == | ||
+ | MP3播放模块,可通串口发送指令操控播放TF卡中保存的歌曲 | ||
+ | |||
+ | |||
+ | == 技术参数 == | ||
+ | * 工作电压: VCC 3.3V -5V | ||
+ | * 串口通信 | ||
+ | * 采用TF卡存储歌曲或语音信息 | ||
+ | * 板载双声道功放,可驱动0.5W喇叭 | ||
+ | * 模块尺寸:24x46x7.5mm | ||
+ | |||
+ | == 引脚定义 == | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | <small>VCC</small> || <small>电源</small> | ||
+ | |- | ||
+ | | <small>RXI</small> || <small>串口接收</small> | ||
+ | |- | ||
+ | | <small>TXD</small> || <small>串口发送</small> | ||
+ | |- | ||
+ | | <small>GND</small> || <small>地</small> | ||
+ | |} | ||
+ | |||
+ | == 使用教程 == | ||
+ | === <small>Arduino示例</small> === | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
#include <SoftwareSerial.h> | #include <SoftwareSerial.h> |
2018年1月8日 (一) 11:53的版本
概述
MP3播放模块,可通串口发送指令操控播放TF卡中保存的歌曲
技术参数
- 工作电压: VCC 3.3V -5V
- 串口通信
- 采用TF卡存储歌曲或语音信息
- 板载双声道功放,可驱动0.5W喇叭
- 模块尺寸:24x46x7.5mm
引脚定义
VCC | 电源 |
RXI | 串口接收 |
TXD | 串口发送 |
GND | 地 |
使用教程
Arduino示例
#include <SoftwareSerial.h> #include "kt540b.h" uint8_t inBuff[3] = { 0 }; uint8_t inByte; Kt540bClass mp3Play(5, 6); void setup() { Serial.begin(115200); mp3Play.begin(); mp3Play.setVolume(50); mp3Play.play(1); } void loop() { for (uint8_t i = 0; i < 3; i++) inBuff[i] = 0; while(Serial.available()) { inByte = Serial.read(); delay(2); if (inByte == 0xff) { inBuff[0] = inByte; Serial.readBytes(&inBuff[1], 2); } //for (uint8_t i = 0; i < 3; i++) //{ // Serial.write(inBuff[i]); //} if (inBuff[1] == 0x01) // 播放指定歌曲 { mp3Play.play(inBuff[2]); } if (inBuff[1] == 0x02) // 播放上下首 { switch (inBuff[2]) { case 0x01: mp3Play.playNext(); break; case 0x02: mp3Play.playPrev(); break; default: break; } } if (inBuff[1] == 0x03) // 设置音量大小 { mp3Play.setVolume(inBuff[2]); } if (inBuff[1] == 0x04) // 音量增加减 { switch (inBuff[2]) { case 0x01: mp3Play.volumeInc(); break; case 0x02: mp3Play.volumeDec(); break; default: break; } } if (inBuff[1] == 0x05) // 暂停、停止播放 { switch (inBuff[2]) { case 0x01: mp3Play.pause(); //暂停 break; case 0x02: mp3Play.play(); //恢复播放 break; case 0x03: mp3Play.stop(); //停止播放 break; default: break; } } } }