Sound sensor

Introduction

The sound transducer is a condenser microphone module, often used to detect and measure sound levels. Sensor sensitivity can be adjusted by means of a potentiometer.

This sensor is ideally suited to threshold measurement. This means that the sensor emits a digital signal as soon as a user-defined threshold value is exceeded.

This sensor has three functional components: detection on the front of the module, which measures the current environment and transmits it as an analog signal to the amplifier. The amplifier amplifies the signal according to the resistance set on the rotary potentiometer, and sends it to the module’s analog output.

The pines of KY-038

Analog : Connect to the analog part of the Arduino board.

GND: Connect to board ground

VCC: Connect to +5V on Arduino board

Digital: Connect to the digital part of the Arduino board.

Electronic diagram

Here is the circuit diagram for connecting the KY-038 sound sensor to the Arduino board:

Programming

Here’s the program to retrieve values from the KY-038 sound pickup. This program does not require a library:

// Declaration and initialization of input pins
int pin_analog = A0; // Analog input
int pin_digital = 3; // Digital input
 
void setup () {
 pinMode (pin_analog, INPUT);
 pinMode (pin_digital, INPUT);
 
Serial.begin (9600); // Serial output at 9600 bauds
}
 
void loop () {
 float Analog;
 int Digital;
 
//Values are read, converted to voltage
 Analog = analogRead (pin_analog) * (5.0 / 1023.0); 
Digital = digitalRead (pin_digital);
 
Serial.print ("Analog voltage:"); Serial.print (Analog, 4); Serial.print ("V, ");
 Serial.print ("Limit:");
 
if(Digital==1) {
 Serial.println ("reached");
 }
 else {
 Serial.println ("not yet reached");
 }
 Serial.println ("----------------------------------------------------------------");
 delay (200);
}