<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Music_Box_One%E2%80%94Key_Version</id>
		<title>Music Box One—Key Version - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Music_Box_One%E2%80%94Key_Version"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Music_Box_One%E2%80%94Key_Version&amp;action=history"/>
		<updated>2026-06-06T05:21:12Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Music_Box_One%E2%80%94Key_Version&amp;diff=10860&amp;oldid=prev</id>
		<title>1304410487@qq.com：Created page with &quot;{{Language| Music Box (Key version) }} {| style=&quot;width: 800px;&quot; |- | ==Objective== Here we build a music box. By a crash switch, you can play, pause and cut music.  File: Mu...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Music_Box_One%E2%80%94Key_Version&amp;diff=10860&amp;oldid=prev"/>
				<updated>2015-10-20T06:44:00Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language| Music Box (Key version) }} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== Here we build a music box. By a crash switch, you can play, pause and cut music.  File: Mu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language| Music Box (Key version) }}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
Here we build a music box. By a crash switch, you can play, pause and cut music. &lt;br /&gt;
[[File: MusicBox_Joystick.jpg|600px|center]]&lt;br /&gt;
==Principle==&lt;br /&gt;
Detect two touch switches' status to trigger music playing, pause and cut.&lt;br /&gt;
[[File:music_boxz.jpg|600px|center]]&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|Module||Number||Function &lt;br /&gt;
|-&lt;br /&gt;
|[[mCookie-CoreUSB]]||1||Core board&lt;br /&gt;
|-&lt;br /&gt;
|[[ mCookie-Hub]]||1||Sensor pin board &lt;br /&gt;
|-&lt;br /&gt;
|[[ mCookie-Audio]]||1||Audio module &lt;br /&gt;
|-&lt;br /&gt;
|[[ mCookie-Amplifier]]||1||Amplifier module&lt;br /&gt;
|-&lt;br /&gt;
| [[mCookie-BM]]||1||Battery management &lt;br /&gt;
|-&lt;br /&gt;
| [[Microduino-Crash]]||2||Crash sensor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Other Equipment: &lt;br /&gt;
**Two loudspeakers &lt;br /&gt;
**One cell of battery &lt;br /&gt;
&lt;br /&gt;
 [[File:music_boxz—module.jpg|600px|center]]&lt;br /&gt;
==Preperation==&lt;br /&gt;
*Setup 1：Connect CoreUSB and PC/MAC with a USB cable, then open Arduino IDE.&lt;br /&gt;
[[File:CoreUSB_Ble_pc.jpg|600px|center]]&lt;br /&gt;
* Setup 2:&lt;br /&gt;
Download program examples: &lt;br /&gt;
[https://github.com/Microduino/Microduino_Tutorials/tree/master/MCookie_Tutorial/music_box music_box]&lt;br /&gt;
[[File: _MusicBox_Crash_ino.jpg|600px|center]]&lt;br /&gt;
* Setup 3：Open downloaded program, choose the right board and COM port , download program. &lt;br /&gt;
[[File: _MusicBox_Crash_ino-ok.jpg|600px|center]]&lt;br /&gt;
==Software Debugging==&lt;br /&gt;
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.&lt;br /&gt;
*&amp;quot; audio.h &amp;quot;controls Audio files and &amp;quot;key.h&amp;quot; detects files when the key is pressed.&lt;br /&gt;
*The use of Audio serial port can be decided by jumper wires on the board. The default soft serial port is (2,3).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;SoftwareSerial.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SoftwareSerial mySerial(2, 3); // RX, TX&lt;br /&gt;
&lt;br /&gt;
#define AUDIO_PORT mySerial   &lt;br /&gt;
//#define AUDIO_PORT mySerial  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
*Key controls pin definition &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int music1_Pin = 4;&lt;br /&gt;
int music2_Pin = 6;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Send serial instructions to control Audio's playing, pause or cut according to if the key is pressed. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  if (key_get(music1_Pin, 0))&lt;br /&gt;
  {&lt;br /&gt;
    delay(200);&lt;br /&gt;
    play_pause = !play_pause;&lt;br /&gt;
  }&lt;br /&gt;
  if (play_change != play_pause)&lt;br /&gt;
  {&lt;br /&gt;
    play_change = play_pause;&lt;br /&gt;
    if (play_pause)&lt;br /&gt;
      audio_play();&lt;br /&gt;
    else&lt;br /&gt;
      audio_pause();&lt;br /&gt;
  }&lt;br /&gt;
  if (key_get(music2_Pin, 0))&lt;br /&gt;
    audio_down();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Hardware Buildup ==&lt;br /&gt;
*Setup1：Connect two Crash switches to D4 and D6 pins of Sensorhub. &lt;br /&gt;
 [[file: music_boxz _4_6.JPG|thumb|800px|center]]&lt;br /&gt;
*Setup 2：Insert TF card into the slot of AudioShield. &lt;br /&gt;
[[File: _MusicBox_Joystick _TF.jpg|600px|center]]&lt;br /&gt;
*Setup 3：Stack Audio and AuidoShield, connect them to PC and then you can save MP3 files into TF card's root directory. &lt;br /&gt;
[[File: _MusicBox_Joystick _song.jpg|600px|center]]&lt;br /&gt;
*Setup4：Connect two loudspeakers to Amplifier. &lt;br /&gt;
[[file: MusicBox_Joystick _song_speak.JPG|600px|center]]&lt;br /&gt;
*Setup5：Stack Audio, AudioShield and Amplifier. 将Audio，Audio shield，Amplifier&lt;br /&gt;
[[file: MusicBox_Joystick _3_speak.JPG|600px|center]]&lt;br /&gt;
*Setup6：Connect the activated battery box and BM. &lt;br /&gt;
[[File:CoreUSB_Ble_steup2.jpg|600px|center]]&lt;br /&gt;
*Setup7：Stack all modules without fixed order (Except that Audio, AudioShield and Amplifier have to be together). &lt;br /&gt;
[[file: MusicBox_Crash _steup_ok.JPG|600px|center]]&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
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. &lt;br /&gt;
[[file: music_boxz _legao.JPG|thumb|800px|center]]&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>1304410487@qq.com</name></author>	</entry>

	</feed>