const int soundSensorPin = 35; // Analog input pin for the sound sensor
void setup() {
Serial.begin(115200);
}
void loop() {
// Read the analog value from the sound sensor
int sensorValue = analogRead(soundSensorPin);
// Convert the analog value to decibels (adjust the mapping as needed)
float voltage = (sensorValue / 1024.0) * 3.3; // Assuming 10-bit ADC and 3.3V reference voltage
float soundindecibels = 20 * log10(voltage / 0.00632); // Adjust 0.00632 according to your sensor's sensitivity
// Print the sound level in decibels to the serial monitor
Serial.print("soundindecibels(dB): ");
Serial.println(soundindecibels);
delay(1000); // Read and print sound level every second
}