Water Sensor with Arduino Nano
SOURCE CODE:
const int waterSens = A0; //define water sensor and set to pin A0 const int led = 9; //define led and set to pin 9 int sensorVal;//create a sensor value variable
void setup() { Serial.begin(9600);//begin the serial monitor pinMode(led, OUTPUT);//set the led as an output
}
void loop() { int sensorVal = analogRead(waterSens); //read the water sensor data
if(sensorVal > 200){//if the sensor senses water digitalWrite(led, HIGH);//turn the led on } else{ if //it doesn't digitalWrite(led, LOW);//turn the led off }
Serial.println(sensorVal);//print the data to the serial monitor
}