查看“Music Player”的源代码
←
Music Player
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Objective== The course will show you how to control Microduino modules to achieve a music player by using Processing. ==Equipment== *'''[[Microduino-Core]]''' *'''[[Microduino-FT232R]]''' *'''[[Microduino-SD]]''' *'''[[Microduino-LM4863]]''' *Other Hardware Equipment **A USB cable **A loudspeaker **A storage card ==Schematic== Just stack the four Microduino modules mentioned above and connect the two wires of the loudspeaker to Microduino-LM4863 ==Program== https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/MicroduinoMusicplayer https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/ProcessingMusicplayer ==Debugging== Step 1:The hardware building of the circuit can refer to: 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 *Insert the storage card into the slot of Microduino SD [[File:301KIT-SD.jpg|600px|center|thumb|301KIT-SD]] *Connect the loudspeaker [[File:301KIT-speaker.jpg|600px|center|thumb|301KIT-Speak]] Build the hardware environment according to the schematic, just like this: [[File:processingMusicplayerConnectionDiagram.jpg|600px|center|thumb]] Step 2:Audio Production *A SoX-based tool will be needed. And you can choose a proper conversion program according to the operational frequency of you Microduino modules. *Extract the file to “Microduino with 16 MHz” folder and put the audio file into the folder, then select “FullRate@16MHz_Mono.bat” |- | [[File:audio-1.jpg|600px|center|thumb|Audio]] |- | *A dialog box will pop up, showing “Press any key to continue...” |- | [[File:audio-2.jpg|600px|center|thumb|Audio]] |- | *After that, there appears a newly created folder and you will find the converted file inside. If failed, you can convert the audio file to “wav” format and have another try. |- | [[File:audio-3.jpg|600px|center|thumb|Audio]] |- | *Copy the converted audio file to the storage card and insert the card into Microduino SD card slot. *Use IED to open the test program offered by Microduino and choose Microduino Core (Atmega328P@16M,5V). Here the things should be noticed before program download: **Since some libraries may have different pin definition, please download the changed libraries and replace the former ones; **The name of the audio file should also be changed to that of the generated audio file. Step 3:Here the code needed: The code of two ends (Processing and Microduino) Microduino: //The code keeps consistent with that of the 301kit of Microduino-LM4863 music player. The difference is the added function of receiving serial data 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: //Get the data of the first serial port. 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); //Add background-image, judge the mouse click, send play or pause instructions to Microduino to control the music player void draw() { image(bg, 0, 0); if (button) { image(play, x, y); port.write("p"); } else { image(pause, x, y); port.write("t"); } } Step 4:Download the code and get it compiled successfully. Step 5:After the system goes well, a disk music player will appear on the screen. Click the button in the middle to see what happens. ==Result== The music player starts or pauses along with the click of the button, just like this:. [[File:processingMusicplayerResult.jpg|600px|center|thumb]] ==Video== |}
返回至
Music Player
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息