查看“Music Box One—Key Version”的源代码
←
Music Box One—Key Version
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{Language| Music Box (Key version) }} {| style="width: 800px;" |- | ==Objective== Here we build a music box. By a crash switch, you can play, pause and cut music. [[File: MusicBox_Joystick.jpg|600px|center]] ==Principle== Detect two touch switches' status to trigger music playing, pause and cut. [[File:music_boxz.jpg|600px|center]] ==Equipment== {|class="wikitable" |- |Module||Number||Function |- |[[mCookie-CoreUSB]]||1||Core board |- |[[ mCookie-Hub]]||1||Sensor pin board |- |[[ mCookie-Audio]]||1||Audio module |- |[[ mCookie-Amplifier]]||1||Amplifier module |- | [[mCookie-BM]]||1||Battery management |- | [[Microduino-Crash]]||2||Crash sensor |} *Other Equipment: **Two loudspeakers **One cell of battery [[File:music_boxz—module.jpg|600px|center]] ==Preperation== *Setup 1:Connect CoreUSB and PC/MAC with a USB cable, then open Arduino IDE. [[File:CoreUSB_Ble_pc.jpg|600px|center]] * Setup 2: Download program examples: [https://github.com/Microduino/Microduino_Tutorials/tree/master/MCookie_Tutorial/music_box music_box] [[File: _MusicBox_Crash_ino.jpg|600px|center]] * Setup 3:Open downloaded program, choose the right board and COM port , download program. [[File: _MusicBox_Crash_ino-ok.jpg|600px|center]] ==Software Debugging== Code description: Judge if the Crash's key is pressed for one part and send serial instructions to control Audio to play, pause and cut according to the status of the key for the other part. *" audio.h "controls Audio files and "key.h" detects files when the key is pressed. *The use of Audio serial port can be decided by jumper wires on the board. The default soft serial port is (2,3). <source lang="cpp"> <source lang="cpp"> #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); // RX, TX #define AUDIO_PORT mySerial //#define AUDIO_PORT mySerial </source> </source> *Key controls pin definition <source lang="cpp"> int music1_Pin = 4; int music2_Pin = 6; </source> *Send serial instructions to control Audio's playing, pause or cut according to if the key is pressed. <source lang="cpp"> if (key_get(music1_Pin, 0)) { delay(200); play_pause = !play_pause; } if (play_change != play_pause) { play_change = play_pause; if (play_pause) audio_play(); else audio_pause(); } if (key_get(music2_Pin, 0)) audio_down(); </source> ==Hardware Buildup == *Setup1:Connect two Crash switches to D4 and D6 pins of Sensorhub. [[file: music_boxz _4_6.JPG|thumb|800px|center]] *Setup 2:Insert TF card into the slot of AudioShield. [[File: _MusicBox_Joystick _TF.jpg|600px|center]] *Setup 3:Stack Audio and AuidoShield, connect them to PC and then you can save MP3 files into TF card's root directory. [[File: _MusicBox_Joystick _song.jpg|600px|center]] *Setup4:Connect two loudspeakers to Amplifier. [[file: MusicBox_Joystick _song_speak.JPG|600px|center]] *Setup5:Stack Audio, AudioShield and Amplifier. 将Audio,Audio shield,Amplifier [[file: MusicBox_Joystick _3_speak.JPG|600px|center]] *Setup6:Connect the activated battery box and BM. [[File:CoreUSB_Ble_steup2.jpg|600px|center]] *Setup7:Stack all modules without fixed order (Except that Audio, AudioShield and Amplifier have to be together). [[file: MusicBox_Crash _steup_ok.JPG|600px|center]] ==Result== Choosing to play, pause and cut songs via the crash switch. You can also build a beautiful shell for your project with LEGO since mCookie can be easily stacked with LEGO. [[file: music_boxz _legao.JPG|thumb|800px|center]] ==Video== |}
该页面使用的模板:
模板:Language
(
查看源代码
)
模板:Nmbox
(
查看源代码
)
返回至
Music Box One—Key Version
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
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
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息