Mechatronics LAB
Published © Apache-2.0

How to build an Arduino sound detector Alarm Project

You can learn in this article How to build an Arduino sound detector Alarm Project step in step complete process.

BeginnerProtip1 hour8,324
How to build an Arduino sound detector Alarm Project

Things used in this project

Hardware components

Arduino uno
×1
Microphone Sound Sensor Module
×1
piezo buzzer
×1
push button
×1
10,000-ohm resistor
×1
breadboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

How to build an Arduino sound detector Alarm Project

Code

Arduino sound detector Alarm Project

Arduino
int RawValue = 0;

// Sound Detector
int SoundPin = 8;
int SoundCount = 0;
int Sensitivity = 2;

// Buzzer
int BuzzerPin = 9;
int BuzzerFreq = 300;

// Button
int ButtonPin = 7;

// Has alarm been triggered?
boolean AlarmTripped = false;

void setup()
{
 pinMode(SoundPin, INPUT);
 pinMode(ButtonPin, INPUT);

 Serial.begin(9600);
 Serial.println("Glass Break Alarm 
   ...");
}

void loop()
{
 // Read Reset Button
 RawValue = digitalRead(ButtonPin);
 if (RawValue == 1)
 {
    // Reset alarm
    AlarmTripped = false;
    SoundCount = 0;
 }

 // Read Sound Detector
 RawValue = digitalRead(SoundPin);
 if (RawValue == 0)
 {
    Serial.print("SOUND DETECTED ... 
       SoundCount: ");
    SoundCount++;
    Serial.println(SoundCount);
    if (SoundCount >= Sensitivity)
    {
       AlarmTripped = true;
    }
 }

 // Sound Alarm if alarm has been 
 // tripped.
 if (AlarmTripped)
 {
    tone(BuzzerPin, BuzzerFreq);
 }
 else
 {
    noTone(BuzzerPin);
 }
}

Credits

Mechatronics LAB

Mechatronics LAB

67 projects • 44 followers
I am Sarful , I am a Mechatronics Engineer & also a teacher I am Interested in the evolution of technology in the automation industry .

Comments