This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zonePump.ino
43 lines (43 loc) · 1.67 KB
/
zonePump.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
void zoneControlPump() {
if (zonePump[zoneNumber]) {
if ((unsigned long)(millis() - lastPumpTimer[zoneNumber]) >= pumpTimer[zoneNumber]) {
if (zoneAutoTimer[zoneNumber]) {
sensor[zoneNumber] = analogRead(sensPin[zoneNumber]);
if (sensor[zoneNumber] >= (triggerLow[zoneNumber] - 10)) {
if (pumpTimer[zoneNumber] <= 360000) {
pumpTimer[zoneNumber] = pumpTimer[zoneNumber] + 60000;
}
else if (pumpTimer[zoneNumber] >= 360000) {
pumpTimer[zoneNumber] = 360000;
}
}
else if (sensor[zoneNumber] <= (triggerLow[zoneNumber] + 10)) {
if (pumpTimer[zoneNumber] > 60000) {
pumpTimer[zoneNumber] = pumpTimer[zoneNumber] - 60000;
}
else if (pumpTimer[zoneNumber] <= 60000) {
pumpTimer[zoneNumber] = 60000;
}
}
}
digitalWrite(output[zoneNumber], LOW);
zoneActive[zoneNumber] = true;
lastSensorReadTime[zoneNumber] = millis();
zonePump[zoneNumber] = false;
zoneManualPump[zoneNumber] = false;
lastManualDayTimer[zoneNumber] = millis();
}
}
else if (zoneManualPump[zoneNumber]) {
if ((unsigned long)(millis() - lastPumpTimer[zoneNumber]) >= pumpTimer[zoneNumber]) {
digitalWrite(output[zoneNumber], LOW);
zoneActive[zoneNumber] = true;
zonePump[zoneNumber] = false;
zoneManualPump[zoneNumber] = false;
lastManualDayTimer[zoneNumber] = millis();
}
}
else if (!zoneManualPump[zoneNumber] && !zonePump[zoneNumber]) {
digitalWrite(output[zoneNumber], LOW);
}
}