#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup() {
Serial.begin(115200);
pinMode(13, OUTPUT);
lcd.begin(16, 2);
lcd.print("no sound :(");
}
void loop() {
int sample = analogRead(A0);
Serial.println(sample);
digitalWrite(13, abs(sample - 512) > 50);
if (abs(sample - 512) > 50) { // If sound is detected
lcd.clear(); // Clear the LCD
lcd.setCursor(0, 0); // Set cursor to the first line
lcd.print("I hear you!"); // Print the message
delay(1000); // Wait for a moment
lcd.clear(); // Clear the message
lcd.setCursor(0, 0); // Set cursor back to the first line
lcd.print("no sound :("); // Print the default message
}
}