1. water1.ino
const int level_pin = A0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int d_water;
float v_water;
d_water = analogRead(level_pin);
v_water = (float)d_water * 5.0 / 1024.0;
Serial.print("D : ");
Serial.print(d_water);
Serial.print(", A : ");
Serial.println(v_water);
delay(1000);
}
2. water2.ino
const int level_pin = A0;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
int d_water;
d_water = analogRead(level_pin);
if(d_water > 260) digitalWrite(LED_BUILTIN, HIGH);
else digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}