Learn interfacing Small Microphone Sound Detection Module KY-038 in Raspberry Pi. Sound sensor acts like a microphone which detects sound signals. The sensor will detect sound signals an provide digital or analog output. The sound sensor can be used to make exciting projects like clap switch. In this article, will make led glow on detection of sound. 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
Raspberry Pi x 1
Step 2: Circuit Time
Following are instruction for making a circuit to interface small sound with Arduino.
- Connect (+) pin and GND pin of the sound sensor to +5v and GND of Raspberry Pi.
- Now, connect D0 pin of the sound sensor to GPIO pin 17 of Raspberry Pi.
- Then connect LED to GPIO pin 27 of Arduino by placing a 220Ω resistor in between long leg of LED and GPIO pin 17.
Step 3: Code Time
This code for Small Microphone Sound Detection Module KY-038 in Raspberry Pi. Firstly, we initialize pin d0 (sound) and led pin. Now, we have to set sound pin as input and led pin as output. We added event detect to detect raising/falling edge of signals. Event detect will get value of signal and send it’s value to callback method. The callback method will check if the value of sound signal, if its is high LED will glow otherwise LED will not glow.
Step 4: Run code to Raspberry Pi
Run the Python program in your Raspberry Pi after setting components as per circuit diagram. The LED will turn on when sound is detected. If you are facing issues while detecting sound, adjust the sensitivity of potentiometer on board.
For running python code in Raspberry PI, visit: raspberrypi.org/documentation/usage/python/
For basic hardware information about Raspberry PI 3, Click here.