This ARDUINO beginners project will show you how to build a sound activated alarm…
Click on video below for full tutorial.
Check us out on Facebook!
Parts List:
affiliate links:
Schematic:
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);
}
}