-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ross_Watering.ino
51 lines (40 loc) · 1.5 KB
/
Ross_Watering.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Water sensing - living wall
*/
// constants won't change. They're used here to set pin numbers:
const int mainRes = 2; // the number of the water sensor for main resevoir
const int resAPin = 3; // the number of the water sensor for resevoir A pin
const int resDPin = 4; // the number of the water sensor for resevoir B pin
const int pump = 13; // the number of the pump pin
// variables will change:
bool mainState = HIGH; // variable for reading the pushbutton status
bool resAState = LOW; // variable for reading the pushbutton status
bool resDState = LOW; // variable for reading the pushbutton status
bool pumpCommand = LOW; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(pump, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(mainRes, INPUT);
pinMode(resAPin, INPUT);
pinMode(resDPin, INPUT);
Serial.begin(9600);
}
void loop() {
// read the state of the pushbutton value:
//mainState = digitalRead(mainRes);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
mainState = digitalRead(mainRes);
resAState = digitalRead(resAPin);
resDState = digitalRead(resDPin);
pumpCommand = (mainState && !resAState && !resDState) || (mainState && !resAState && resDState) || (mainState && resAState && !resDState);
Serial.println(pumpCommand);
if (pumpCommand == HIGH) {
// turn LED on:
digitalWrite(pump, HIGH);
}
else {
// turn LED off:
digitalWrite(pump, LOW);
}
}