/* Water Level Detector Sensor: XKC-Y25-V The LED lights up when water is detected. LCD display sends a text warning. Pinout: Sensor --> Arduino Signal --> pin6 -------LCD--------- SDA --> A4 SCL --> A5 */ #include LiquidCrystal_I2C lcd(0x3F, 16, 2); int sensorPin = 6; // Signal of sensor level --> pin 6 int ledPin = 13; // The number of the LED pin int estadoSensor=0; // Guarda el estado del boton void setup() { lcd.init(); lcd.backlight(); //Turn on the backlight lcd.setCursor(0, 0); // Go to column 0, row 0 lcd.print("Water Level Sensor"); pinMode(ledPin, OUTPUT); pinMode(sensorPin, INPUT); } void loop() { estadoSensor = digitalRead(sensorPin); lcd.setCursor (0, 1); if (estadoSensor == HIGH) { digitalWrite(ledPin, HIGH); lcd.print("With water "); } else { digitalWrite(ledPin, LOW); lcd.print("Without water"); } delay(10); }