SURYATEJA
Published © Apache-2.0

Clap Switch Using Sound Sensor

Magic with claps. Switch on light using clap.

BeginnerFull instructions provided22,294
Clap Switch Using Sound Sensor

Things used in this project

Story

Read more

Custom parts and enclosures

Clap Switch

Schematics

Clap Switch

Code

Clap Switch

Arduino
const int ledpin=13; // led pin and sound pin are not changed throughout the process
const int soundpin=A2;
const int threshold=200; // sets threshold for sound sensor
void setup() {
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
pinMode(soundpin,INPUT);
}
void loop() {
	int soundsens=analogRead(soundpin); // read analog data from sensor
	if (soundsens>=threshold) {
		digitalWrite(ledpin, HIGH); // turn led on
		delay(1000);
	}
	else{
		digitalWrite(ledpin, LOW);
	}
}

Credits

SURYATEJA

SURYATEJA

18 projects • 59 followers

Comments