“Music Box(Joystick)”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
Schematic
Software Debuge
 
(未显示2个用户的7个中间版本)
第4行: 第4行:
 
|
 
|
 
==Overview==
 
==Overview==
Build a music box, can play the music files in the TF card, select the song with  
+
Build a music box here! You can play the music files in the TF card, select the song with Joystic rocker and change volume.
 +
[[File: MusicBox_Joystick.jpg|600px|center]]
  
Joystic rocker, and the volume of operation.
 
[[File: MusicBox_Joystick.jpg|600px|center]]
 
 
==Schematic==
 
==Schematic==
Rocker XY direction movement detection by reading the analog value to judge. At
+
By reading the analog value, you can detect and judgeg the Joystic's movement in the X-Y direction.At the same time, you can choose the control mode according to the stay time.
  
the same judge to stay the length of time to select the control mode.
 
 
[[File: MusicBox_Joystick-sch_E.jpg|600px|center]]
 
[[File: MusicBox_Joystick-sch_E.jpg|600px|center]]
  
第38行: 第36行:
  
 
  [[File: MusicBox_Joystick-module.jpg|600px|center]]
 
  [[File: MusicBox_Joystick-module.jpg|600px|center]]
[[File: MusicBox_Joystick-module1.jpg|600px|center]]
+
[[File: MusicBox_Joystick-module1_E.jpg|600px|center]]
 +
 
 
==Code==
 
==Code==
 
*Setup 1:Connect the CoreUSB module to your computer and then start the  
 
*Setup 1:Connect the CoreUSB module to your computer and then start the  
第51行: 第50行:
 
[[File: _MusicBox_Joystick _ino-ok.jpg|600px|center]]
 
[[File: _MusicBox_Joystick _ino-ok.jpg|600px|center]]
  
==Software Debuge==
+
==Software Debugging==
 
*” audio.h” Audio lib file
 
*” audio.h” Audio lib file
*Audio module Serial use D2, D3
+
*Audio module Serial uses D2, D3
 
<source lang="cpp">
 
<source lang="cpp">
 
#include <SoftwareSerial.h>
 
#include <SoftwareSerial.h>
第63行: 第62行:
 
*Detection rocker value
 
*Detection rocker value
 
<source lang="cpp">
 
<source lang="cpp">
int uiStep()        //change songs
+
int uiStep()        //Change songs
 
{
 
{
 
   if (analogRead(A0) < 100)  //Y-up
 
   if (analogRead(A0) < 100)  //Y-up
第81行: 第80行:
 
     delay(50);      //50 ms delay
 
     delay(50);      //50 ms delay
 
     if (analogRead(A1) > 900)  //
 
     if (analogRead(A1) > 900)  //
       return 3;      //return 3
+
       return 3;      //Return to 3
 
   }
 
   }
 
   return 0;
 
   return 0;
第87行: 第86行:
 
</source>
 
</source>
  
*OLED Display interface, user can change it
+
*OLED displays interface and user can change it.
 
<source lang="cpp">
 
<source lang="cpp">
  //The main interface, can be freely to changes
+
  //The main interface can be freely changed.
 
void draw()
 
void draw()
 
{
 
{
第129行: 第128行:
 
[[file: MusicBox_Joystick _song_speak.JPG|600px|center]]
 
[[file: MusicBox_Joystick _song_speak.JPG|600px|center]]
 
*Setup5:Stack the Amplifier, Audio, and Audio Shield modules.
 
*Setup5:Stack the Amplifier, Audio, and Audio Shield modules.
[[file: MusicBox_Joystick _3_speak.JPG|600px|center]]
+
[[file: MusicBox_Joystick _3_speak_E.JPG|600px|center]]
 
*Setup6:Connect the activated Battery module to your Battery Management  
 
*Setup6:Connect the activated Battery module to your Battery Management  
  
第139行: 第138行:
  
 
building the circuit!
 
building the circuit!
[[file: MusicBox_Joystick _steup_ok.JPG|600px|center]]
+
[[file: MusicBox_Joystick _steup_ok_E.JPG|600px|center]]
  
 
==How to Operate==
 
==How to Operate==
[[file: MusicBox_Joystick _caozuo.JPG|600px|center]]
+
[[file: MusicBox_Joystick _caozuo-E.JPG|600px|center]]
 +
 
 
==Result==
 
==Result==
 
Control music playback, pause and change songs by using Joystick. You can also build a nice look LEGO Shell.
 
Control music playback, pause and change songs by using Joystick. You can also build a nice look LEGO Shell.

2015年10月30日 (五) 02:16的最新版本

Language English

Overview

Build a music box here! You can play the music files in the TF card, select the song with Joystic rocker and change volume.

Schematic

By reading the analog value, you can detect and judgeg the Joystic's movement in the X-Y direction.At the same time, you can choose the control mode according to the stay time.

Equipment

Module Number Function
mCookie-CoreUSB/zh 1 Core board
mCookie-Hub/zh 1 Sensor pin board
mCookie-Audio/zh 1 Audio Module
mCookie-Amplifier/zh 1 Power amplifier module
mCookie-BM/zh 1 Battery Management
Microduino-Joystick/zh 1 JoyStick
  • Other Equipment:
    • 2 Speaker
    • 1 Batteray
    • 1 TF card

Code

  • Setup 1:Connect the CoreUSB module to your computer and then start the

Arduino IDE.

  • Setup 2:Select Files>Examples>mCokie>_203_MusicBox_Joystick
  • Setup 3:Click upload button to upload program. When "Done Uploading"

appears, the program should have successfully been uplloaded into the CoreUSB.

Software Debugging

  • ” audio.h” Audio lib file
  • Audio module Serial uses D2, D3
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

#define AUDIO_PORT mySerial
  • Detection rocker value
int uiStep()         //Change songs
{
  if (analogRead(A0) < 100)  //Y-up
  {
    delay(50);       //50 ms delay
    if (analogRead(A0) < 100)      //
      return 1;      //return 1
  }
  if (analogRead(A1) < 100)    //
  {
    delay(50);       //50 ms delay
    if (analogRead(A1) < 100)  //X-Right
      return 2;      //return 2
  }
  if (analogRead(A1) > 900)    //X-Left
  {
    delay(50);       //50 ms delay
    if (analogRead(A1) > 900)  //
      return 3;      //Return to 3
  }
  return 0;
}
  • OLED displays interface and user can change it.
 //The main interface can be freely changed. 
void draw()
{
  setFont_L;

  u8g.setPrintPos(4, 16);
  u8g.print("Music_sta:");
  u8g.print(music_status ? "play" : "pause");

  u8g.setPrintPos(4, 16 * 2);
  u8g.print("Music_vol:");
  u8g.print(music_vol);
  u8g.print("/30");
  u8g.setPrintPos(4, 16 * 3);
  u8g.print("Music_num:");
  u8g.print(music_num);
  u8g.print("/");
  u8g.print(music_num_MAX);
  u8g.setPrintPos(4, 16 * 4);
  u8g.print("....Microduino....");
  //u8g.print(rtc.formatTime(RTCC_TIME_HMS));
}

Hardware Buildup

  • Setup 1:Using the above diagram as reference, connect the sensors into the

corrensponding ports on the Hub module.

  • Setup 2:Insert a micro SD card into the Audio Shield.
MusicBox Joystick TF.jpg
  • Setup 3:Stack the Audio Shield and Audio modules.Even though your micro SD

card may be able to store many songs, the program we provide only supports up

to 9 songs.

MusicBox Joystick song.jpg
  • Setup4:Connect the speakers into the Amplifier module.
MusicBox Joystick song speak.JPG
  • Setup5:Stack the Amplifier, Audio, and Audio Shield modules.
  • Setup6:Connect the activated Battery module to your Battery Management

module.

CoreUSB Ble steup2.jpg
  • Setup7:Stack all the modules together in any order you like (Except three

Audio modules, They must be together). Congratulations, you have finished

building the circuit!

How to Operate

Result

Control music playback, pause and change songs by using Joystick. You can also build a nice look LEGO Shell.

Video