How To Use Sound Sensor ? Control LED By Clap Using Arduino And Sound Sensor

In this article we are showing how to use KY-038 Sound Sensor using Arduino. Also showing how you can control LED by clap with the help of Arduino and Sound Sensor. We have shown only to control LED but by using the same concept you can control any electronic device.

KY-038 Sound Sensor having 4 Pins :-

  1.  AO  – Analog Output
  2. G – Ground
  3. + – VCC
  4. DO – Digital Output

Components Required :-

  1. 1 x Arduino Uno Board
  2. 1 x USB cable
  3. 1 x KY-038 Sound Sensor
  4. 1 x 1K Pull up Register
  5. 5 x Male to Female Jumper Wire
  6. 1 x Breadboard
  7. 1 x LED

Connection :-

Source Code :-

int soundSensor=2;
int LED=4;
boolean LEDStatus=false;

void setup() {
 pinMode(soundSensor,INPUT);
 pinMode(LED,OUTPUT);

}

void loop() {

  int SensorData=digitalRead(soundSensor); 
  if(SensorData==1){

    if(LEDStatus==false){
        LEDStatus=true;
        digitalWrite(LED,HIGH);
    }
    else{
        LEDStatus=false;
        digitalWrite(LED,LOW);
    }
  }
 } 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *