This tutorial will show you how to make a clap or loud sound activated light or relay.
click on video below for full tutorial
Check us out on Facebook!
Parts List:
affiliate links:
Schematic:
ARDUINO Code:
int val = 0;
int last = 0;
#define sound 3
#define light 9
void setup() {
pinMode(sound, INPUT);
pinMode(light, OUTPUT);
}
void loop() {
val = digitalRead(sound);
if (val == 1 && last == 0)
{
digitalWrite (light, HIGH);
last = 1;
delay(500);
}
else if (val == 1 && last == 1)
{
digitalWrite (light, LOW);
last = 0;
delay(500);
}
}