Created
November 20, 2018 14:06
-
-
Save ulitiy/c4ea030499b4b5dd8b975530c6a841d1 to your computer and use it in GitHub Desktop.
Auto fill your kettle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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