Skip to content

Instantly share code, notes, and snippets.

@ulitiy
Created November 20, 2018 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulitiy/c4ea030499b4b5dd8b975530c6a841d1 to your computer and use it in GitHub Desktop.
Save ulitiy/c4ea030499b4b5dd8b975530c6a841d1 to your computer and use it in GitHub Desktop.
Auto fill your kettle
void setup() {
pinMode(A0, INPUT);
digitalWrite(A0, HIGH);
pinMode(A2, OUTPUT);
digitalWrite(A2, LOW);
}
void loop() {
delay(50);
int waterLevel = digitalRead(A0); // Read sensor
delay(50);
int waterLevel1 = digitalRead(A0);
if(waterLevel != waterLevel1) // debounce
return;
if(waterLevel == HIGH){ // EMPTY // In the last version should be HIGH
digitalWrite(A2, HIGH); // TURN ON WATER
} else { // FULL
digitalWrite(A2, LOW); // TURN OFF WATER
delay(300000); // Wait until the user no longer needs hot water
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment