int val ;
int WaterPin = 3;
int LED_Pin = 5;
int Switch = 6;
boolean flag = true;
void blink_LED();
void setup() {
Serial.begin(9600);
pinMode(WaterPin,INPUT);
pinMode(LED_Pin,OUTPUT);
pinMode(Switch,OUTPUT);
digitalWrite(LED_Pin,LOW);
digitalWrite(Switch,HIGH);
}
void loop() {
val = digitalRead(WaterPin);
Serial.print("WaterPin:");
Serial.println(val);
if(val == LOW && flag == true)
{
digitalWrite(Switch,LOW);
delay(200);
while(1)
{ blink_LED();
if(digitalRead(WaterPin)==HIGH)
{
digitalWrite(LED_Pin,LOW);
break;
}
}
flag = false;
}
if(val == HIGH && flag == false)
{
digitalWrite(Switch,HIGH);
flag = true;
}
delay(10);
}
void blink_LED()
{
digitalWrite(LED_Pin,LOW);
delay(200);
digitalWrite(LED_Pin,HIGH);
delay(200);
}