const int waterSens = A0; //define water sensorconst int led = 9;//define led to pin 9int waterVal; //define the water sensor value
void setup() {pinMode(led, OUTPUT); //set led as an outputpinMode(waterSens, INPUT);//set water sensor as an inputSerial.begin(9600); //start the serial port at 9600 bauds
}
void loop() { waterVal = analogRead(waterSens); //read the water sensor Serial.println(waterVal); //print the value of the water sensor to the serial monitorif (waterVal <= 0){ digitalWrite(led, HIGH);//if the water sensor senses water turn the led on}else{ digitalWrite(led, LOW);//if it doesn't sense anything turn the led off}}