Jobin J Jose
Published

Clap Switch: Control LED with Sound

A simple Arduino setup using a sound sensor, your clap is detected and triggers an LED to turn on or off.

BeginnerShowcase (no instructions)3 hours6
Clap Switch: Control LED with Sound

Things used in this project

Story

Read more

Schematics

Circuit Diagram

Code

Arduino Code

C/C++
// Clap Switch Project
// Turns LED on/off with a clap sound

const int soundSensor = A0;   // Sound sensor connected to A0
const int ledPin = 7;         // LED connected to digital pin 7
int sensorValue = 0;
bool ledState = false;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(soundSensor, INPUT);
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(soundSensor);
  Serial.println(sensorValue);

  if (sensorValue > 500) { // adjust threshold based on your environment
    ledState = !ledState;  // toggle LED state
    digitalWrite(ledPin, ledState);
    delay(500); // debounce delay
  }
}

Credits

Jobin J Jose
11 projects • 1 follower

Comments