Vibration Alarm

来自Microduino Wikipedia
跳转至: 导航搜索
Language English

Objective

To make a vibration alarm and when there is vibration, the buzzer will set off alarm audio twice.

Principle

Equipment

Module Number Function
Microduino-CoreUSB 1 Core board
Microduino-Sensorhub 1 Sensor pin board
Microduino-BM 1 Battery management
Microduino-BUZZER 1 Buzzer sensor
Microduino-Shock 1 Vibration sensor
  • Other Equipment:
    • One battery

Hardware Buildup

  • Setup 1:Connect CoreUSB to the computer, open program examples, select the right board and serial port, then download the program.

SHOCK_alarm

  • Setup 2:Stack CoreUSB and Sensorhub together
  • Setup3:Connect vibration sensor to the D4 pin of Sensorhub and buzzer sensor to D6.
Microduino-sensorhub rule.JPG
  • Setup4:Connect the battery to BM.

Software Debugging

  • Function description:
    • " buzzer()" : Buzzer alarm control function.
  • Control Pin Description
#define pushButton 4 //Vibration 
#define speakPin 6 //Buzzer
  • Judge if there is vibration in two seconds.
  if (millis() - time > 2000)
  {
    if (!digitalRead(pushButton))
      shock = false;
    time = millis();
  }
  • When detecting vibration, the buzzer will set alarm for twice repeatedly. Users can change alarm times.
  if (shock)
  {
    for (int j = 0; j < 2; j++)
      buzzer();
  }
  else
    noTone(speakPin);

Result

When knocking on the vibration sensor, the buzzer will make alarm twice and will stop when there is no vibration after the alarm. You can also build a beautiful shell with LEGO for the project since mCookie can be easily stacked with LEGO boards. 。

Video