Difference between revisions of "Music Box One—Key Version"
From Microduino Wiki
(Created page with "{{Language| Music Box (Key version) }} {| style="width: 800px;" |- | ==Objective== Here we build a music box. By a crash switch, you can play, pause and cut music. File: Mu...") |
|||
Line 33: | Line 33: | ||
[[File:music_boxz—module.jpg|600px|center]] | [[File:music_boxz—module.jpg|600px|center]] | ||
− | == | + | ==Preparation== |
*Setup 1:Connect CoreUSB and PC/MAC with a USB cable, then open Arduino IDE. | *Setup 1:Connect CoreUSB and PC/MAC with a USB cable, then open Arduino IDE. | ||
[[File:CoreUSB_Ble_pc.jpg|600px|center]] | [[File:CoreUSB_Ble_pc.jpg|600px|center]] |
Latest revision as of 09:20, 4 August 2017
Language: | English • 中文 |
---|
ContentsObjectiveHere we build a music box. By a crash switch, you can play, pause and cut music. PrincipleDetect two touch switches' status to trigger music playing, pause and cut. Equipment
Preparation
Download program examples: music_box
Software DebuggingCode 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.
<source lang="cpp">
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
#define AUDIO_PORT mySerial
//#define AUDIO_PORT mySerial </source>
int music1_Pin = 4;
int music2_Pin = 6;
if (key_get(music1_Pin, 0))
{
delay(200);
play_pause = !play_pause;
}
if (play_change != play_pause)
{
play_change = play_pause;
if (play_pause)
audio_play();
else
audio_pause();
}
if (key_get(music2_Pin, 0))
audio_down(); Hardware Buildup
ResultChoosing 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. Video |