Add code for water leak detection
This commit is contained in:
parent
355eb681da
commit
b90448e69f
1 changed files with 26 additions and 0 deletions
26
sodaq_one/water.ino
Normal file
26
sodaq_one/water.ino
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue