ARDUINO Beginners Project : Sound Activated Alarm

This ARDUINO beginners project will show you how to build a sound activated alarm…

Click on video below for full tutorial.

 

 

Parts List:

ARDUINO Board

Sound Sensor

8ohm speaker

Jumper Wires

Bread Board

 

 

Schematic:

audio_alarm_schem

audio_alarm_schem_2

 

 

ARDUINO Code:

 

int val = 0;
#define sound 3

void setup() {
pinMode(sound,INPUT);
}

void loop() {
val = digitalRead(sound);

if (val == 1)
{
for (int x = 0; x < 5; x++)
{
tone(9, 500, 500);
delay(500);
tone(9, 800, 500);
delay(500);
}
delay(500);
}

}

 

ARDUINO Code for using a relay and car alarm horn:

int val = 0;
#define sound 3
#define alarm 9

void setup() {
pinMode(sound,INPUT);
}

void loop() {
val = digitalRead(sound);

if (val == 1)
{
digitalWrite (alarm,HIGH);
delay(10000); // change this value to how long you want the alarm to stay on
digitalWrite (alarm,LOW);
}

}