/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-water-sensor */ #define POWER_PIN 14 #define SIGNAL_PIN A0 int value = 0; // variable to store the sensor value void setup() { Serial.begin(9600); pinMode(POWER_PIN, OUTPUT); // configure D7 pin as an OUTPUT digitalWrite(POWER_PIN, LOW); // turn the sensor OFF } void loop() { digitalWrite(POWER_PIN, HIGH); // turn the sensor ON delay(10); // wait 10 milliseconds value = analogRead(SIGNAL_PIN); // read the analog value from sensor digitalWrite(POWER_PIN, LOW); // turn the sensor OFF Serial.print("Sensor value: "); Serial.println(value); delay(1000); }