Difference between revisions of "Birthday Lamp Project (X02)"
(→Preparation) |
(→Hardware Buildup) |
||
Line 147: | Line 147: | ||
==Hardware Buildup== | ==Hardware Buildup== | ||
− | + | '''NOTE''': When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them. | |
− | + | #Connect the Buzzer to the Sensor Hub on Pin 6/7 | |
− | + | #Connect the Crash sensor to the Sensor Hub on Pin 4/5 | |
− | + | #Grab the mCookie USBTTL or mBattery and Stack the mCookie Core on top. | |
− | + | #Stack the mCookie LED Matrix on top of that. | |
− | + | #Stack the mCookie Sensor on top of that. | |
− | + | #Plug in the MicroUSB cable to the mCookie USBTTL or mBattery to a computer. | |
− | |||
− | |||
− | |||
==Result== | ==Result== |
Revision as of 21:25, 3 January 2017
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. .SchematicThe Core module detects if the Crash switch is pressed. The variable holding the status of the Crash switch will change to True if the switch is pressed and False if the switch is not pressed. If True, the project will play the Happy Birthday music and light up. If False, no music will play and the lights will be off. Equipment
Preparation1. Connect mCookie Core to the PC with the USB Cable. Open the Microduino IDE. 2. Go to File > Examples > 00.mCookie > _101_BirthdayLight 3. Select the board, processor and port:
4. Upload the program by clicking on the right arrow icon on the top left of the window. Or under Sketch > Upload. 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 BuildupNOTE: When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them.
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 |