Noise Alarm--Grumpy Grandpa
From Microduino Wiki
Language: | English • 中文 |
---|
ContentsObjectiveThe "Grumpy Grandpa" can't stand the noise. As soon as he heard big noise, the device will alarm. You can press the switch to stop the alarm. PrincipleWith MIC sound detection sensor to detect sound, when the sound exceeds the pre-et value, the device starts timing. In order to prevent interference, if the sound which keeps maintain louder than the default value after a certain period of time, then it is considered to be noise and the buzzer will alarm. At the same time, the system can detect whether the key is pressed,. When the key press, the buzzer alarm is closed. Equipment
Preparation
Program Description
#define mic_pin A0
#define buzzer_pin 6
#define key_pin 4
#define voice 400
if (voice_data > voice)
{
if (millis() - time > 500 )
{
voice_data = analogRead(mic_pin);
if (voice_data > voice)
{
buzzer_speak = true;
i = 200;
}
time = millis();
}
}
if (key_get(key_pin, 0))
{
delay(200);
buzzer_speak = false;
time = millis();
}
if (buzzer_speak)
buzzer();
else
noTone(buzzer_pin); Hardware Buildup
ResultShouting towards the sound detector and keep that for a while, the buzzer will make alarm. By pressing the key, the alarm will stop. Video |