Birthday Lamp

来自Microduino Wikipedia
1304410487@qq.com讨论 | 贡献2015年7月31日 (五) 06:50的版本 (Created page with "{{Language| Birthday Lantern}} {| style="width: 800px;" |- | ==Objective== To make a birthday lantern, press the button and play the music via a buzzer and you can see flashin...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索
Language English

Objective

To make a birthday lantern, press the button and play the music via a buzzer and you can see flashing lamp.

Principle

Device

Module Number Function
Microduino-CoreUSB 1 Core board
Microduino-Sensorhub 1 Sensor pinboard
Microduino-BM 1 Buttery
Microduino-BUZZER 1 Buzzer
Microduino-Lantern 1 colored light
  • Other
    • Battery

Hardware Building

  • Setup 1:Stack CoreUSB and Sensorhub.
  • Setup 2:Connect Buzzer to the D6 pin of Sensorhub, the Colored led to A0 and the crash switch to D2.
Microduino-sensorhub rule.JPG

Software Debugging

  • Setup 1:Start programing. Build development environment and download program code.

music_birth

  • Setup 2:Code description
  • Function
    • “playNote()”Sound control
    • “colorSet()”Color control
    • “blink()”Pause
  • Pin description
#define PIXEL_PIN    A0 //Colored light 

int key_Pin = 2;  //Key 
int speakerPin = 6;  //Buzzer
  • Light change (Red, green, blue and yellow)
      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));
  • Play music
      if (!play_pause)
      {
        play_pause = false;
        noTone(speakerPin);
        return;
      }
      playNote(notes[i], beats[i]); // make sound

Result

Press the crash switch, it will play music and the lights start flashing and turning brighter. Press the key again, it will turn off the music and the light.

Video