Add code for water leak detection

This commit is contained in:
Nico Schottelius 2016-11-14 11:01:40 +01:00
parent 355eb681da
commit b90448e69f
1 changed files with 26 additions and 0 deletions

26
sodaq_one/water.ino Normal file
View File

@ -0,0 +1,26 @@
#include <Arduino.h>
void setupWater(int pin) {
pinMode(pin, INPUT);
}
boolean hasWater(int pin)
{
if(digitalRead(pin) == LOW) {
return true;
} else {
return false;
}
}
String getWater(int pin)
{
String tmp;
if(hasWater(pin)) {
tmp = "water=1";
} else {
tmp = "water=0";
}
return tmp;
}