Clap-Activated Light

Published: August 27, 2025

A simple sound-reactive project that uses a sound sensor to detect claps or loud noises and toggles an LED on or off with each clap โ€” just like a clap switch lamp.


๐Ÿ“ธ Preview

Clap-activated light project preview

โš™๏ธ How It Works:


๐Ÿงฐ Parts & Materials Used

ComponentNotesAmazon Link to parts
Arduino UNO (Real & Clone)Microcontroller boardReal - Link
Clone - Link
Sound Sensor ModuleKY-038 or similar (uses digital OUT)Link
LEDFor visual feedbackLink
220ฮฉ ResistorIn series with LEDLink
Breadboard + jumper wiresFor easy connectionsLink

Disclaimer: The Amazon links provided above are affiliate links. This means I may earn a small commission at no extra cost to you if you make a purchase through them.


๐Ÿ”Œ Wiring Instructions

๐Ÿ”‰ Sound Sensor

Sensor PinConnect to
VCC5V
GNDGND
OUT (D0)D2

Use the digital output pin (OUT) on the sound sensor โ€” not the analog one (A0).

๐Ÿ’ก LED with Resistor

LED LegConnect to
Long leg (+)D8 via 220ฮฉ resistor
Short leg (โ€“)GND

๐Ÿ“ž Arduino Code

Language: C++

#const int soundSensorPin = 2;  // Digital OUT from sound sensor
const int ledPin = 8;          // LED connected to pin 8

bool ledState = false;
bool soundDetected = false;

void setup() {
  pinMode(soundSensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int sensorValue = digitalRead(soundSensorPin);

  // Detect sound pulse (goes LOW on sound)
  if (sensorValue == LOW && !soundDetected) {
    ledState = !ledState;           // Toggle LED state
    digitalWrite(ledPin, ledState); // Apply the new state
    soundDetected = true;
    delay(200);                     // Debounce delay
  }

  // Reset detection flag when sound passes
  if (sensorValue == HIGH) {
    soundDetected = false;
  }
}

๐Ÿงช Notes:

๐Ÿš€ Uploading the Code

  1. Open Arduino IDE
  2. Paste the code
  3. Select your Arduino UNO board and port
  4. Click Upload โ†‘

← Back to Projects