// Pin definitions const int soundSensorPin = A1; // GPIO 0 for sound sensor const int ledPin = D7; // GPIO 1 for LED // Threshold for sound level to detect speech const float speechThreshold = 39.0; // Adjust this threshold as needed void setup() { pinMode(soundSensorPin, INPUT); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // Ensure LED is initially off Serial.begin(9600); } void loop() { // Read the analog value from the sound sensor int soundValue = analogRead(soundSensorPin); // Convert analog value to decibels (assuming linear relationship, may vary with sensor) float soundDecibel = 20 * log10(soundValue); // Print the sound level in decibels to the serial monitor Serial.print("Sound level (dB): "); Serial.println(soundDecibel); // If sound level exceeds the speech threshold, turn on the LED if (soundDecibel > speechThreshold) { digitalWrite(ledPin, HIGH); // Turn on LED } else { digitalWrite(ledPin, LOW); // Turn off LED } // Add a delay to avoid flooding the serial monitor delay(500); }