Difference between revisions of "Music Box(Joystick)"
From Microduino Wiki
(→How to Operate) |
(→Software Debuge) |
||
Line 54: | Line 54: | ||
==Software Debuge== | ==Software Debuge== | ||
*” audio.h” Audio lib file | *” audio.h” Audio lib file | ||
− | *Audio module Serial | + | *Audio module Serial uses D2, D3 |
<source lang="cpp"> | <source lang="cpp"> | ||
#include <SoftwareSerial.h> | #include <SoftwareSerial.h> | ||
Line 64: | Line 64: | ||
*Detection rocker value | *Detection rocker value | ||
<source lang="cpp"> | <source lang="cpp"> | ||
− | int uiStep() // | + | int uiStep() //Change songs |
{ | { | ||
if (analogRead(A0) < 100) //Y-up | if (analogRead(A0) < 100) //Y-up | ||
Line 82: | Line 82: | ||
delay(50); //50 ms delay | delay(50); //50 ms delay | ||
if (analogRead(A1) > 900) // | if (analogRead(A1) > 900) // | ||
− | return 3; // | + | return 3; //Return to 3 |
} | } | ||
return 0; | return 0; | ||
Line 88: | Line 88: | ||
</source> | </source> | ||
− | *OLED | + | *OLED displays interface and user can change it. |
<source lang="cpp"> | <source lang="cpp"> | ||
− | //The main interface | + | //The main interface can be freely changed. |
void draw() | void draw() | ||
{ | { |
Revision as of 01:58, 30 October 2015
Language: | English • 中文 |
---|
ContentsOverviewBuild a music box, can play the music files in the TF card, select the song with Joystic rocker, and the volume of operation. SchematicRocker XY direction movement detection by reading the analog value to judge. At the same judge to stay the length of time to select the control mode. Equipment
Code
Arduino IDE.
appears, the program should have successfully been uplloaded into the CoreUSB. Software Debuge
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
#define AUDIO_PORT mySerial
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;
}
//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
corrensponding ports on the Hub module.
card may be able to store many songs, the program we provide only supports up to 9 songs.
module.
Audio modules, They must be together). Congratulations, you have finished building the circuit! How to OperateResultControl music playback, pause and change songs by using Joystick. You can also build a nice look LEGO Shell. Video |