Birthday Lamp Project (X02)
From Microduino Wiki
ContentsOverviewPress the Crash switch and the Buzzer will play the Happy Birthday song. The LEDs will also flash. Double press the Crash switch to stop. This guide is written for the second generation mCookie kits. .SchematicSystem can detect if the crash switch is collided. If yes, the status including True and False will change once. When it is True, the device will play music and get lighted. conversely, it'll stop playing music and turn off the light. Equipment
Preparation
Program description
#define PIXEL_PIN A0 //Colored led
int key_Pin = 2; //Key
int speakerPin = 6; //Buzzer
void blink()
{
if (key_get(key_Pin, 0)) //Press the key
{
delay(200); //Shockproof
play_pause = !play_pause; // Status changes one time.
}
}
add++;
if (add == 5)
add = 1;
if (add == 1)
colorSet(strip.Color(i * 10, 0, 0));
else if (add == 2)
colorSet(strip.Color(0, i * 10, 0));
else if (add == 3)
colorSet(strip.Color(0, 0, i * 10));
else if (add == 4)
colorSet(strip.Color(i * 10, i * 10, 0));
int notes[] = {
NOTE_C4, NOTE_C4, NOTE_D4, NOTE_C4, NOTE_F4, NOTE_E4,
NOTE_C4, NOTE_C4, NOTE_D4, NOTE_C4, NOTE_G4, NOTE_F4,
NOTE_C4, NOTE_C4, NOTE_C5, NOTE_A4, NOTE_F4, NOTE_E4, NOTE_D4,
NOTE_AS4, NOTE_AS4, NOTE_A4, NOTE_F4, NOTE_G4, NOTE_F4
}; Hardware Buildup
If modules do not work normally, please try to cut off and power supply and restart it. ResultPress crash switch, play birthday song and get lighted. The light will get brighter and brighter. Then press the switch once more, the music and light will be turned off. Video |