Difference between revisions of "Music Box Three—Infrared Control"
(→Equipment) |
(→Result) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
==Principle== | ==Principle== | ||
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. | 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. | ||
− | [[File: MusicBox_Remote-sch.jpg|600px|center]] | + | [[File: MusicBox_Remote controller-sch.jpg|600px|center]] |
+ | |||
==Equipment== | ==Equipment== | ||
{|class="wikitable" | {|class="wikitable" | ||
Line 173: | Line 174: | ||
[[file: MusicBox_Joystick _song_speak.JPG|600px|center]] | [[file: MusicBox_Joystick _song_speak.JPG|600px|center]] | ||
*Setup5:Make sure you stack Audio, AudioShield and Amplifier together. | *Setup5:Make sure you stack Audio, AudioShield and Amplifier together. | ||
− | [[file: MusicBox_Joystick | + | [[file: MusicBox_Joystick _3_speaker.JPG|600px|center]] |
*Setup6:Connect the activated battery box with the BM module. | *Setup6:Connect the activated battery box with the BM module. | ||
[[File:CoreUSB_Ble_steup2.jpg|600px|center]] | [[File:CoreUSB_Ble_steup2.jpg|600px|center]] | ||
*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! | *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! | ||
− | [[file: | + | [[file: MusicBox_Remote controller_steup_ok.JPG|600px|center]] |
+ | |||
==How to operate == | ==How to operate == | ||
You can push the corresponding button of the remote controller to change songs or volume. | You can push the corresponding button of the remote controller to change songs or volume. | ||
− | [[file: MusicBox_Remote _ir.JPG|600px|center]] | + | [[file: MusicBox_Remote _ir receiver.JPG|600px|center]] |
You can also control the music box with the Joystick, as follows: | You can also control the music box with the Joystick, as follows: | ||
− | [[file: MusicBox_Joystick | + | [[file: MusicBox_Joystick _cc caozuo.JPG|600px|center]] |
− | Also you can choose DUO-V to be stacked with OLED so as to reduce the stacking height. | + | Also you can choose DUO-V to be stacked with OLED so as to reduce the stacking height. |
+ | |||
==Result== | ==Result== | ||
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. | 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. | ||
− | [[file: | + | [[file: MusicBox_Remote_okay.JPG|600px|center]] |
==Video== | ==Video== | ||
|} | |} |
Latest revision as of 15:24, 5 March 2016
Language: | English • 中文 |
---|
ContentsObjectiveBuild a music box here! You can play music files in the TF card and change songs & volume with a remote controller or a Joystick. PrincipleThe 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. Equipment
Code
Software Debugging
if (irrecv.decode(&results)) {
//Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
if (results.value == 0xFFA857)
{
music_status = !music_status; //Play or pause
if (music_status == true) //Play
{
Serial.println("play"); //Serial outputs "PLAY"
audio_play(); //Audio starts to work.
}
else //Pause
{
Serial.println("pause"); //Serial outputs "PAUSE"
audio_pause(); //Audio pauses.
}
}
else if (results.value == 0xFF906F)//Next song
{
music_num++; //Music number +
if (music_num > music_num_MAX) //Limit the number of songs if it is larger than 30.
{
music_num = 1; //Music number returns to 1.
}
music_status = true;
audio_choose(music_num);
audio_play();
eeprom_WRITE();
}
else if (results.value == 0xFFE01F)//Last song
{
music_num--; //Music number reduces one.
if (music_num < 1) // Limit the song number if it is less than one.
{
music_num = music_num_MAX; //Maximum music number (Here is nine.)
}
music_status = true;
audio_choose(music_num); //Audio chooses music number.
audio_play(); //Audio play
eeprom_WRITE();
}
else if (results.value == 0xFF02FD)//Volume+
{
music_vol++; //Volume+ 1
if (music_vol > 30) music_vol = 1; //If the volume is more than 30, then it returns to 3.
audio_vol(music_vol);
music_status = true;
eeprom_WRITE();
}
else if (results.value == 0xFF9867)//Volume-
{
music_vol--; // Volume-1
if (music_vol < 1) music_vol = 30; // If the volume is less than 1, then it returns to 30.
audio_vol(music_vol);
music_status = true;
eeprom_WRITE();
}
}
else
results.value = 0;
int uiStep() //Change songs
{
if (analogRead(A0) < 100) //Y-up
{
delay(50); //50ms delay
if (analogRead(A0) < 100) //
return 1; //Return to 1
}
if (analogRead(A1) < 100) //
{
delay(50); //50ms delay
if (analogRead(A1) < 100) //X-Right
return 2; //Return to 2
}
if (analogRead(A1) > 900) //X-Left
{
delay(50); //50ms delay
if (analogRead(A1) > 900) //
return 3; //Return to 3
}
return 0;
}
//Main interface, which can be defined freely by users.
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
How to operateYou can push the corresponding button of the remote controller to change songs or volume. You can also control the music box with the Joystick, as follows: Also you can choose DUO-V to be stacked with OLED so as to reduce the stacking height. ResultTo 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. Video |