Vibration Alarm

From Microduino Wiki
Revision as of 03:28, 22 October 2015 by 1304410487@qq.com (talk) (Created page with "{{Language| Vibration Alarm}} {| style="width: 800px;" |- | ==Objective== To make a vibration alarm and when there is vibration, the buzzer will set off alarm audio twice. ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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