Learn interfacing Small Microphone Sound Detection Module KY-038 in Arduino. A small sound sensor acts like a microphone that detects sound signals. The sensor will detect sound signals a provide digital or analog output. The sound sensor can be used to make exciting projects like clap switch. This article will make led glow on the detection of sound. For this, we will be using a small sound sensor KY-038 and Arduino Uno. So, let’s start.
Step 1: Required Components
Small Microphone Sound Detection Module KY-038 x 1
Generic LED x 1
Breadboard x 1
220Ω Resistor x 1
Arduino Uno Board x 1
Step 2: Circuit Time
The following are instructions for making a circuit to interface the small sound detection module with Arduino.
- Connect (+) pin and GND pin of the sound sensor to +5v and GND of Arduino.
- Now, connect the D0 pin of the sound sensor to digital pin 7 of Arduino.
- Then connect LED to pin 13 of Arduino by placing a 220Ω resistor in between long leg of the LED and digital pin 13.
Step 3: Code Time
This code for Small Microphone Sound Detection Module KY-038 in Arduino. Firstly, we initialize pin d0 (sound) and led pin. The output of the sensor will be 0 or 1, so, we declare val as boolean and initialize it to 0. We will set the sound pin as input and led pin as an output. In the loop, we check the value of output. If the output is high (sound detected) then LED will turn on otherwise it will remain off.
Step 4: Upload the code to Arduino
Upload the above-given code to the Arduino UNO Board after the components are set as per the Circuit Diagram. The LED turns on and off based on sound detection.
Learn more information about uploading code to Arduino Uno.