Noise Alarm

From Microduino Wiki
Jump to: navigation, search
Language: English  • 中文

Objective

When noise reaches a certain value around you, the alarm goes off.


Principle

Equipment

Module Number Function
Microduino-CoreUSB 1 Core board
Microduino-Sensorhub 1 Sensor pinboard
Microduino-Mic 1 Sound detection sensor
Microduino-Crash 1 Crash/touch switch
Microduino-BUZZER 1 Buzzer sensor
Microduino-BM 1 Battery management

Hardware Buildup

  • Setup 1:Connect CoreUSB to your PC, open program example, choose the right board and download program via the serial port.
  • Setup2:Connect Mic to the A0 pin of Sensorhub, buzzer to D6 and crash sensor to D4.
Microduino-sensorhub rule.JPG
  • Setup6:Connect battery to BM.

Software Debugging

  • Build IDE, connect CoreUSB to your PC and download program code.

Noise_alarm Code description

  • Control pin description
#define mic_pin A0
#define buzzer_pin 6
#define key_pin 4
  • Sound pre-set value
  #define voice 400
  • If the sound value is greater than the preset value in one second, then the buzzer will give an alarm.
    if (voice_data > voice)
  {
    if (millis() - time > 1000 )
    {
      voice_data = analogRead(mic_pin);
      if (voice_data > voice)
      {
        buzzer_speak = true;
        i = 200;
      }
      time = millis();
    }
  }
  • Touch the key to close the sound.
      if (key_get(key_pin, 0))
  {
    delay(200);
    buzzer_speak = false;
    time = millis();
  }

Result

If the sound around you exceeds the default value within one second, the alarm will go off. You can press the key and close the sound. (You can also build a beautiful cover with LEGO.)

Video