Shall we go further and explain how to use the sound sensor? Controlling an LED by clapping using an Arduino and a sound sensor. We cover how to use the KY-038 Sound Sensor with Arduino. It also shows how you can control a clapping LED using an Arduino and a sound sensor. We've only shown clapping LED control, but you can use the same concept to control any electronic device. Once you watch the whole video, you will understand everything.
What is the sound sensor KY-038?
KY-038 A small sound sensor works as a microphone that detects sound signals. The sensor detects audio signals and provides a digital or analog output. The sound sensor can be used to create exciting projects like clapping a switch or any project where we can do action-based sound detection. It is very cheap, you can buy it for 2-3 USD dollars. Let's take a look at the architecture of KY-038:-
Sound sensor KY-038 with 4 pins:-
AO – Analog output
G – ground
+ – VCC
DO – Digital output
How the KY-038 sensor works:-
The sensor has 3 main components on its board. First, a sensor unit on the front of the module that physically measures the area and sends an analog signal to the second unit, the amplifier. The amplifier amplifies the signal according to the resistance value of the potentiometer and sends the signal to the analog output of the module. The third component is a comparator that turns off the digital output and LED if the signal falls below a certain value.
We can control the sensitivity by adjusting the potentiometer connected to the KY-38 sensor.
Note: The signal will be inverted; that is, if you measure a high value, it will appear as a low voltage value on the analog output.
7 Components Needed to Control LED Clap Using Arduino and Sound Sensor:-
- 1 Arduino Uno board
- 1 USB cable
- 1 KY-038 sound sensor
- 1 1K pull-up register
- 5 male to female connecting cable
- 1 cutting board
- 1 LED
Do the Connection like this :-
Here is our Source Code:-
// This code is written by supotronix.com
int soundSensor=2;
int LED=4;
boolean LEDStatus=false;
void setup() {
pinMode(soundSensor,INPUT);
pinMode(LED,OUTPUT);
}
void loop() {
// here is the loop is continue
int SensorData=digitalRead(soundSensor);
if(SensorData==1){
if(LEDStatus==false){
LEDStatus=true;
digitalWrite(LED,HIGH);
}
else{
LEDStatus=false;
digitalWrite(LED,LOW);
}
}
}
0 Comments