“音乐播放器”的版本间的差异
(→设备) |
|||
| 第8行: | 第8行: | ||
==设备== | ==设备== | ||
| − | *'''[[Microduino-Core]]''' | + | *'''[[Microduino-Core/zh]]''' |
| − | *'''[[Microduino- | + | *'''[[Microduino-USBTTL/zh]]''' |
| − | *'''[[Microduino-SD]]''' | + | *'''[[Microduino-SD/zh]]''' |
| − | *'''[[Microduino- | + | *'''[[Microduino-Amplifier/zh]]''' |
| 第17行: | 第17行: | ||
**USB数据连接线 一根 | **USB数据连接线 一根 | ||
**喇叭 一个 | **喇叭 一个 | ||
| − | **存储卡 一张 | + | **存储卡 一张 |
==原理图== | ==原理图== | ||
2014年10月29日 (三) 07:27的版本
| Language | English |
|---|
目的本教程将教大家如何用processing来控制Microduino实现的音乐播放器。 设备
原理图堆叠设备说明中的四个Microduino模块,喇叭的两根线接到Microduino-LM4863即可 程序调试步骤一:硬件搭建类似于Microduino KIT示例教程的Microduino LM4863音乐播放器-301KIT:http://www.microduino.cc/wiki/index.php?title=Microduino_LM4863%E9%9F%B3%E4%B9%90%E6%92%AD%E6%94%BE%E5%99%A8-301KIT/zh
|
|
|
本例需要两端的代码,Processing端和Microduino端 Microduino: //代码与Microduino LM4863音乐播放器-301KIT基本一致,不同的是添加了接收串口数据功能 if(Serial.available())
{
command=Serial.read();
Serial.println(command);
SdPlay.worker();
if(num_two!=num_one)
{
num_two=num_one ;
if(command=='p') {//’p’ means play
SdPlay.play();
Serial.println(F("Play."));
}
else if(command=='t') {//’t’ means stop
SdPlay.pause();
Serial.println(F("Pause."));
}
Serial.println(ok);
Serial.print(num_one);
Serial.println(num_two);
}
}
Processing: //得到第一个串口的数据。 println(Serial.list()); // is always my Arduino, so I open Serial.list()[0]. // Open whatever port is the one you're using. port = new Serial(this, Serial.list()[0], 9600); //添加背景图,判断鼠标点击,发送播放或暂停到Microduino控制音乐播放器 void draw() {
image(bg, 0, 0);
if (button) {
image(play, x, y);
port.write("p");
}
else {
image(pause, x, y);
port.write("t");
}
}
步骤五:运行后,屏幕上会出现一个唱片播放器,点击中间的按钮看看有什么反应。 结果鼠标点击播放按钮后,播放器开始播放音乐,暂停后音乐暂停,像这样
视频 |






