<?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_Three%E2%80%94Infrared_Control</id>
		<title>Music Box Three—Infrared Control - 版本历史</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_Three%E2%80%94Infrared_Control"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Music_Box_Three%E2%80%94Infrared_Control&amp;action=history"/>
		<updated>2026-06-06T07:20:13Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Music_Box_Three%E2%80%94Infrared_Control&amp;diff=11143&amp;oldid=prev</id>
		<title>1304410487@qq.com：Created page with &quot;{{Language| Music Box Three--Infrared Control }} {| style=&quot;width: 800px;&quot; |- | ==Objective== Build a music box here! You can play music files in the TF card and change songs &amp;...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Music_Box_Three%E2%80%94Infrared_Control&amp;diff=11143&amp;oldid=prev"/>
				<updated>2015-10-30T02:50:15Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language| Music Box Three--Infrared Control }} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== Build a music box here! You can play music files in the TF card and change songs &amp;amp;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language| Music Box Three--Infrared Control }}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
Build a music box here! You can play music files in the TF card and change songs &amp;amp; volume with a remote controller or a Joystick. &lt;br /&gt;
[[File: MusicBox_Remote.jpg|600px|center]]&lt;br /&gt;
==Principle==&lt;br /&gt;
The principle is to detect if there is matched infrared remote control signal and play music according to different infrared signal. At the same time, it can detect and judge the Joystick's movement in the X-Y direction by reading the analog value. It'll choose the control mode according to the stay time.  &lt;br /&gt;
[[File: MusicBox_Remote-sch.jpg|600px|center]]&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-OLED]||1||OLED display &lt;br /&gt;
|-&lt;br /&gt;
| [[mCookie-BM]]||1||Battery management &lt;br /&gt;
|-&lt;br /&gt;
| [[Microduino-Joystick]]||1||Joystick sensor &lt;br /&gt;
|-&lt;br /&gt;
| [[Microduino-IR receiver]]||1||Infrared receiver &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Other Equipment: &lt;br /&gt;
**Two loudspeakers &lt;br /&gt;
**One battery &lt;br /&gt;
**One TF card &lt;br /&gt;
**One infrared remote controller  &lt;br /&gt;
 [[File: MusicBox_Remote-module.jpg|600px|center]]&lt;br /&gt;
==Code==&lt;br /&gt;
*Setup 1：Connect the CoreUSB to the computer via a USB cable and open Arduino IDE. &lt;br /&gt;
[[File:CoreUSB_Ble_pc.jpg|600px|center]]&lt;br /&gt;
* Setup 2：Click Files &amp;gt; Examples &amp;gt; mCookie &amp;gt; _302_MusicBox_Remote and then load the program.  &lt;br /&gt;
[[File: _ MusicBox_Remote_ino.jpg|600px|center]]&lt;br /&gt;
* Setup 3：Select the right board and COM port for program download. When it pops up &amp;quot;Done Uploading&amp;quot; notice, it means the program has been written into the CoreUSB module.  &lt;br /&gt;
[[File: _ MusicBox_Remote _ino-ok.jpg|600px|center]]&lt;br /&gt;
==Software Debugging==&lt;br /&gt;
*Infrared Control   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
if (irrecv.decode(&amp;amp;results)) {&lt;br /&gt;
    //Serial.println(results.value, HEX);&lt;br /&gt;
    irrecv.resume(); // Receive the next value&lt;br /&gt;
&lt;br /&gt;
    if (results.value == 0xFFA857)&lt;br /&gt;
    {&lt;br /&gt;
      music_status = !music_status;	//Play or pause &lt;br /&gt;
      if (music_status == true)	//Play &lt;br /&gt;
      {&lt;br /&gt;
        Serial.println(&amp;quot;play&amp;quot;);   //Serial outputs &amp;quot;PLAY&amp;quot;  &lt;br /&gt;
        audio_play();              //Audio starts to work.  &lt;br /&gt;
      }&lt;br /&gt;
      else	//Pause  &lt;br /&gt;
      {&lt;br /&gt;
        Serial.println(&amp;quot;pause&amp;quot;);   //Serial outputs &amp;quot;PAUSE&amp;quot;  &lt;br /&gt;
        audio_pause();              //Audio pauses. &lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else if (results.value == 0xFF906F)//Next song  &lt;br /&gt;
    {&lt;br /&gt;
      music_num++;	//Music number +&lt;br /&gt;
      if (music_num &amp;gt; music_num_MAX)	//Limit the number of songs if it is larger than 30.   &lt;br /&gt;
      {&lt;br /&gt;
        music_num = 1; //Music number returns to 1.  &lt;br /&gt;
      }&lt;br /&gt;
      music_status = true;&lt;br /&gt;
      audio_choose(music_num);&lt;br /&gt;
      audio_play();&lt;br /&gt;
      eeprom_WRITE();&lt;br /&gt;
    }&lt;br /&gt;
    else if (results.value == 0xFFE01F)//Last song  &lt;br /&gt;
    {&lt;br /&gt;
      music_num--;	//Music number reduces one.   &lt;br /&gt;
      if (music_num &amp;lt; 1)	// Limit the song number if it is less than one.&lt;br /&gt;
      {&lt;br /&gt;
        music_num = music_num_MAX;   //Maximum music number (Here is nine.)&lt;br /&gt;
      }&lt;br /&gt;
      music_status = true;&lt;br /&gt;
      audio_choose(music_num);       //Audio chooses music number. &lt;br /&gt;
&lt;br /&gt;
      audio_play();                  //Audio play &lt;br /&gt;
      eeprom_WRITE();&lt;br /&gt;
    }&lt;br /&gt;
    else if (results.value == 0xFF02FD)//Volume+ &lt;br /&gt;
    {&lt;br /&gt;
      music_vol++;                 //Volume+ 1&lt;br /&gt;
      if (music_vol &amp;gt; 30) music_vol = 1; //If the volume is more than 30, then it returns to 3.   &lt;br /&gt;
      audio_vol(music_vol);&lt;br /&gt;
      music_status = true;&lt;br /&gt;
      eeprom_WRITE();&lt;br /&gt;
    }&lt;br /&gt;
    else if (results.value == 0xFF9867)//Volume-  &lt;br /&gt;
    {&lt;br /&gt;
      music_vol--;                   // Volume-1    &lt;br /&gt;
      if (music_vol &amp;lt; 1) music_vol = 30; // If the volume is less than 1, then it returns to 30.&lt;br /&gt;
      audio_vol(music_vol);&lt;br /&gt;
      music_status = true;&lt;br /&gt;
      eeprom_WRITE();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  else&lt;br /&gt;
    results.value = 0;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
*Detect the joystick value  &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int uiStep()         //Change songs  &lt;br /&gt;
{&lt;br /&gt;
  if (analogRead(A0) &amp;lt; 100)  //Y-up&lt;br /&gt;
  {&lt;br /&gt;
    delay(50);       //50ms delay &lt;br /&gt;
    if (analogRead(A0) &amp;lt; 100)      //&lt;br /&gt;
      return 1;      //Return to 1  &lt;br /&gt;
  }&lt;br /&gt;
  if (analogRead(A1) &amp;lt; 100)    //&lt;br /&gt;
  {&lt;br /&gt;
    delay(50);       //50ms delay   &lt;br /&gt;
    if (analogRead(A1) &amp;lt; 100)  //X-Right&lt;br /&gt;
      return 2;      //Return to 2  &lt;br /&gt;
  }&lt;br /&gt;
  if (analogRead(A1) &amp;gt; 900)    //X-Left&lt;br /&gt;
  {&lt;br /&gt;
    delay(50);       //50ms delay  &lt;br /&gt;
    if (analogRead(A1) &amp;gt; 900)  //&lt;br /&gt;
      return 3;      //Return to 3&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*OLED display interface, which is available to be changed by users. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 //Main interface, which can be defined freely by users.  &lt;br /&gt;
void draw()&lt;br /&gt;
{&lt;br /&gt;
  setFont_L;&lt;br /&gt;
&lt;br /&gt;
  u8g.setPrintPos(4, 16);&lt;br /&gt;
  u8g.print(&amp;quot;Music_sta:&amp;quot;);&lt;br /&gt;
  u8g.print(music_status ? &amp;quot;play&amp;quot; : &amp;quot;pause&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  u8g.setPrintPos(4, 16 * 2);&lt;br /&gt;
  u8g.print(&amp;quot;Music_vol:&amp;quot;);&lt;br /&gt;
  u8g.print(music_vol);&lt;br /&gt;
  u8g.print(&amp;quot;/30&amp;quot;);&lt;br /&gt;
  u8g.setPrintPos(4, 16 * 3);&lt;br /&gt;
  u8g.print(&amp;quot;Music_num:&amp;quot;);&lt;br /&gt;
  u8g.print(music_num);&lt;br /&gt;
  u8g.print(&amp;quot;/&amp;quot;);&lt;br /&gt;
  u8g.print(music_num_MAX);&lt;br /&gt;
  u8g.setPrintPos(4, 16 * 4);&lt;br /&gt;
  u8g.print(&amp;quot;....Microduino....&amp;quot;);&lt;br /&gt;
  //u8g.print(rtc.formatTime(RTCC_TIME_HMS));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Hardware Buildup==&lt;br /&gt;
*Setup 1：Use the wire to connect the OLED to the IIC interface of the Hub, then install the Joystick sensor to A0, A1 and the IR receiver sensor to D6.&lt;br /&gt;
[[File: _ MusicBox_Remote _hub.jpg|600px|center]]&lt;br /&gt;
*Setup 2：Insert the TF card into the slot of AudioShield.   &lt;br /&gt;
[[File: _MusicBox_Joystick _TF.jpg|600px|center]]&lt;br /&gt;
*Setup 3：Stack the Audio and AudioShield to the PC, and you can save MP3 files into the TF card. (Here we can save 9 to the most.)&lt;br /&gt;
[[File: _MusicBox_Joystick _song.jpg|600px|center]]&lt;br /&gt;
*Setup4：Connect the two loudspeakers to the Amplifier. &lt;br /&gt;
[[file: MusicBox_Joystick _song_speak.JPG|600px|center]]&lt;br /&gt;
*Setup5：Make sure you stack Audio, AudioShield and Amplifier together.   &lt;br /&gt;
[[file: MusicBox_Joystick _3_speak.JPG|600px|center]]&lt;br /&gt;
*Setup6：Connect the activated battery box with the BM module. &lt;br /&gt;
[[File:CoreUSB_Ble_steup2.jpg|600px|center]]&lt;br /&gt;
*Setup7：Stack all modules together without fixed order.(Except for Audio, AudioShield and Amplifier should be connected with each other). Congratulations! You just finished the circuit buildup! &lt;br /&gt;
[[file: MusicBox_Remote_steup_ok.JPG|600px|center]]&lt;br /&gt;
==How to operate ==&lt;br /&gt;
You can push the corresponding button of the remote controller to change songs or volume.  &lt;br /&gt;
[[file: MusicBox_Remote _ir.JPG|600px|center]]&lt;br /&gt;
You can also control the music box with the Joystick, as follows:&lt;br /&gt;
[[file: MusicBox_Joystick _caozuo.JPG|600px|center]]&lt;br /&gt;
Also you can choose DUO-V to be stacked with OLED so as to reduce the stacking height.  &lt;br /&gt;
==Result==&lt;br /&gt;
To play, pause or change songs with an infrared remote controller of Joystick to control. Here you can also build a beautiful shell for your project with LEGO since mCookie can be easily stacked with LEGO boards. &lt;br /&gt;
[[file: MusicBox_Remote_ok.JPG|600px|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>