const int sensorPin = A0;
const int buzzerPin = 8;
const int threshold = 700; // Set your water level threshold
void setup() {
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int waterLevel = analogRead(sensorPin);
Serial.print("Water Level: ");
Serial.println(waterLevel);
if (waterLevel > threshold) {
// Make a tone continuously (e.g. 1000 Hz)
tone(buzzerPin, 1000);
} else {
// Stop tone
noTone(buzzerPin);
}
delay(100);
}