Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------- ZONE COMMAND HV TACO ---------------------
- // ---------------------4 ZONE CONTROL BOARD-------------------
- // ------------------------I2C LCD DISPLAY---------------------
- // --------------------4 USER INPUT BUTTONS--------------------
- // -------------------DESIGNED AND PROGRAMMED BY:--------------
- // --------------------------COREY EARL-------------------------
- // ----------------REVISION 3 (AUG 5th, 2021)----------------
- // ----------------All Zones Appear to Function----------------
- // ---------------------More Testing Needed--------------------
- //----------------Ready for on-site BETA testing---------------
- //----------------------------FEATURES:-----------------------------
- //-----------------Easy to deactivate/activate each zone------------
- //---------------------Watchdog timers for each zone ---------------
- //----------------Easy trigger point setting per zone---------------
- //--Triggering of wagtchdog attempts to fail individual zones safe--
- //---------Per zone fault indication when watchdog triggered--------
- //--------------------------ISSUES:---------------------------------
- //-------EEPROM not working right, more testing needed--------
- //--------------------------------------------------------
- // Libraries
- #include <EEPROM.h>
- #include <LiquidCrystal_I2C.h>
- #include <Wire.h>
- LiquidCrystal_I2C lcd(0x27, 20, 4); // Set I2C Address and display size
- // Which zones are active. If a zone is active set as true, if a zone is
- // deactived or not needed set to false. Zones are then placed in an array.
- bool zoneActive[] = {true,true,true,true};
- // Counter for progressing through each Zone
- int zoneNumber = 0; // Which zone the loop is controlling
- // If the zone is in a fault state;
- bool faultFlash[] = {false,false,false,false};
- // Sensor trigger points to trigger each zones output on/off.
- // NOTE: GIKFUN 1.2 Moisture sensors seem to range from ~340(Capacitor submerged
- // in water) to ~670(Dry air)
- // GIKFUN 2.0 Seem to run this range (~290 wet, ~700 Dry) but responds
- // much slower as moisture increases, responds quickly to drying). These
- // tests done with factory ~8" jumper harness. Will retest with final
- // length harnesses and adjust MiniTaco V1.0 Soil Sensors seem to run from
- // ~700 - ~930. - 8" Harness, retest with 7.5' Harness MiniTaco V1.5 Soil
- // Sensors seem to run from ~490 - ~890. - 8" Harness, retest with 7.5'
- // Harness
- int triggerHigh[] = {550, 550, 550, 550};
- int triggerLow[] = {800, 800, 800, 800};
- // ---Pin Assignments--
- // Set Pin Assignments for User Input Buttons
- const int button1 = 10;
- const int button2 = 11;
- const int button3 = 12;
- const int button4 = 13;
- // Set Pin Assignments for Zone Status LED's
- const int zoneLED[] = {6, 7, 8, 9}; // Zone 1-4 pins for LEDs
- // Set pin assignments for OUT pins
- const int output[] = {2, 3, 4, 5}; // Zone 1-4 pins for outputs to relays
- const int sensPin[] = {A0, A1, A2, A3}; // Zone 1-4 Analog ADC pins
- // --Variables--
- // Menu Related Variables
- bool menuOn = true; // state of the display menu
- int menu[5]; // number of menu items
- int optionSelect = 0; // which menu option is selected
- int lastOptionSelect = 0;
- int lastItemSelect = 0;
- int itemSelect = 0;
- int buttonState1 = 0; // current state of each button
- int buttonState2 = 0;
- int buttonState3 = 0;
- int buttonState4 = 0;
- int lastButtonState1 = 0; // previous state of each button
- int lastButtonState2 = 0;
- int lastButtonState3 = 0;
- int lastButtonState4 = 0;
- unsigned long displayTimer = 10000; // timer to automatically turn off the display
- unsigned long lastDisplayTimer = 0;
- // Delay Variables
- const int sensorReadDelay[] = {500, 500, 500, 500}; // delay between sensor readings in millis
- unsigned long lastSensorReadTime[] = {0, 0, 0, 0}; // the last time a sensor was read
- // Watchdog timers to monitor zone "on" time of each output. 600000 = 10 minutes
- unsigned long watchDog[] = {600000, 600000, 600000, 600000}; // Watchdog timers in array
- // Last value of the Watchdog timers
- unsigned long lastWatchDog[] = {0, 0, 0, 0}; // last value of Watchdog timers in array
- // Fault LED flash timers
- const int flashLED[] = {500, 500, 500, 500}; // write flash timers to array
- unsigned long lastFlashLED[] = {0, 0, 0, 0}; // write last flash times to array
- // Analog sensor reading values sensors 1-4
- int sensor[] = {0, 0, 0, 0}; // Sensor reading values array
- // Sensor pins 1-4 states ("1" = Low, "2" = Neutral, "3" = High)
- int zoneState[] = {0, 0, 0, 0}; // Zone pin state array
- // Output pin values outputs 1-4
- int outRead[] = {0, 0, 0, 0}; // Output pin value array
- // Output LED pin values outputs 1-4
- int ledState[] = {0, 0, 0, 0}; // Zone Active LED high/low array
- // EEPROM addresses
- const int zone1TrigAddress = 0;
- const int zone2TrigAddress = 1;
- const int zone3TrigAddress = 2;
- const int zone4TrigAddress = 3;
- const int firstRun = 4; // Address to tell the memory if this is the first time this chip has run.
- int startUp;
- void setup() {
- // put your setup code here, to run once:
- lcd.begin();
- lcd.clear();
- lcd.home();
- lcd.print(" --ZONE COMMAND--");
- lcd.setCursor(0, 1);
- lcd.print(" Irrigation");
- lcd.setCursor(0, 2);
- lcd.print(" System");
- lcd.setCursor(0, 3);
- lcd.print(" LOADING...");
- delay(2000);
- lcd.clear();
- // set LED indicator pins to output.
- pinMode(zoneLED[0], OUTPUT);
- pinMode(zoneLED[1], OUTPUT);
- pinMode(zoneLED[2], OUTPUT);
- pinMode(zoneLED[3], OUTPUT);
- // set OUT pins to output
- pinMode(output[0], OUTPUT);
- pinMode(output[1], OUTPUT);
- pinMode(output[2], OUTPUT);
- pinMode(output[3], OUTPUT);
- // set Sensor pins to input
- pinMode(sensPin[0], INPUT);
- pinMode(sensPin[1], INPUT);
- pinMode(sensPin[2], INPUT);
- pinMode(sensPin[3], INPUT);
- // set Button pins to input
- pinMode(button1, INPUT);
- pinMode(button2, INPUT);
- pinMode(button3, INPUT);
- pinMode(button4, INPUT);
- }
- void zoneControl() {
- if (zoneActive[zoneNumber]) {
- sensor[zoneNumber] = analogRead(sensPin[zoneNumber]);
- digitalWrite(zoneLED[zoneNumber], HIGH); // Turn Zone Indicator LED On
- if ((unsigned long)(millis() - lastWatchDog[zoneNumber]) >= watchDog[zoneNumber]) { // If the watchdog timer has been triggered
- zoneActive[zoneNumber] = false; // turn off the zone
- faultFlash[zoneNumber] = true; // turn on the fault light
- digitalWrite(zoneLED[zoneNumber], LOW); // Turn Zone Indicator LED Off
- }
- else if ((unsigned long)(millis() - lastSensorReadTime[zoneNumber]) >= sensorReadDelay[zoneNumber]) {
- lastSensorReadTime[zoneNumber] = millis();
- // Set the sensor reading levels for the output trigger for sensor
- if (sensor[zoneNumber] >= triggerLow[zoneNumber]) {
- zoneState[zoneNumber] = 1; // Reading is above trigger, turn on relay
- digitalWrite(output[zoneNumber], HIGH);
- }
- else if (sensor[zoneNumber] >= triggerLow[zoneNumber] && sensor[zoneNumber] <= triggerHigh[zoneNumber]) {
- zoneState[zoneNumber] = 2; // Reading is in between triggers, maintain relay state
- lastWatchDog[zoneNumber] = millis();
- }
- else if (sensor[zoneNumber] <= triggerHigh[zoneNumber]) {
- zoneState[zoneNumber] = 3; // Reading is below trigger, turn off relay
- digitalWrite(output[zoneNumber], LOW);
- lastWatchDog[zoneNumber] = millis();
- }
- }
- }
- }
- // Running the Fault Flash
- void faultFlashLED() {
- if (faultFlash[zoneNumber]) { // if the zone is in a fault state
- ledState[zoneNumber] = digitalRead(zoneLED[zoneNumber]); // check state of zone indicator LED
- if ((unsigned long)(millis() - lastFlashLED[zoneNumber]) >= flashLED[zoneNumber]) {
- lastFlashLED[zoneNumber] = millis();
- if (ledState[zoneNumber] == HIGH) {
- digitalWrite(zoneLED[zoneNumber], LOW);
- }
- else if (ledState[zoneNumber] == LOW) {
- digitalWrite(zoneLED[zoneNumber], HIGH);
- }
- }
- digitalWrite(output[zoneNumber], LOW); // shut the relay off
- }
- }
- // Loop to progress zoneControl and fault monitor through each zone
- void zoneLoop() {
- for (zoneNumber = 0; zoneNumber < 3; zoneNumber++) {
- zoneControl();
- faultFlashLED();
- }
- for (zoneNumber = 3; zoneNumber > 0; zoneNumber = 0) {
- zoneControl();
- faultFlashLED();
- }
- }
- void readButtons() {
- buttonState1 = (digitalRead(button1));
- buttonState2 = (digitalRead(button2));
- buttonState3 = (digitalRead(button3));
- buttonState4 = (digitalRead(button4));
- if (buttonState1 != lastButtonState1) {
- if (buttonState1 == LOW) { // if the DOWN button has been pressed
- lastDisplayTimer = millis();
- if ((optionSelect != 0) && (itemSelect != 5)) { // if we are not in the settings change and not passed the last screen.
- itemSelect++;
- }
- else if ((optionSelect != 0) && (itemSelect = 5)) {
- itemSelect = 0;
- }
- }
- lastButtonState1 = buttonState1;
- }
- if (buttonState4 != lastButtonState4) {
- if (buttonState4 == LOW) { // if the UP button has been pressed
- lastDisplayTimer = millis();
- if ((optionSelect != 0) && (itemSelect != 0)) { // if we are not in the settings change and not passed the first screen.
- itemSelect--;
- }
- }
- lastButtonState4 = buttonState4;
- }
- if (itemSelect == 0) { // if we are not adjusting settings
- if (buttonState2 !=
- lastButtonState2) { // if the right button has been pressed
- if (buttonState2 == LOW) { // if the right button has been pressed
- lastDisplayTimer = millis();
- if ((optionSelect <= 4) &&
- (optionSelect != 4)) { // if we are not past the last menu screen
- optionSelect++;
- }
- else if (optionSelect == 4) { // if we are at the last menu screen
- optionSelect = 0;
- }
- }
- lastButtonState2 = buttonState2;
- }
- if (buttonState3 !=
- lastButtonState3) { // if the left button has been pressed
- if (buttonState3 == LOW) { // if the left button has been pressed
- lastDisplayTimer = millis();
- if (optionSelect > 0) { // if we are not at the first menu screen
- optionSelect--;
- }
- else if (optionSelect == 0) {
- optionSelect = 4;
- }
- }
- lastButtonState3 = buttonState3;
- }
- }
- else if (itemSelect == 2) { // if we are adjusting settings
- buttonState2 = (digitalRead(button2));
- buttonState3 = (digitalRead(button3));
- if (buttonState2 !=
- lastButtonState2) { // if the right button has been pressed
- if (buttonState2 == LOW) { // if the right button has been pressed
- lastDisplayTimer = millis();
- if (optionSelect == 1) { // if we are adjusting Zone 1
- triggerLow[0] = (triggerLow[0] + 25);
- }
- else if (optionSelect == 2) { // if we are adjusting Zone 2
- triggerLow[1] = (triggerLow[1] + 25);
- }
- else if (optionSelect == 3) { // if we are adjusting Zone 3
- triggerLow[2] = (triggerLow[2] + 25);
- }
- else if (optionSelect == 4) { // if we are adjusting Zone 4
- triggerLow[3] = (triggerLow[3] + 25);
- }
- }
- lastButtonState2 = buttonState2;
- lcd.clear();
- }
- if (buttonState3 !=
- lastButtonState3) { // if the left button has been pressed
- if (buttonState3 == LOW) { // if the left button has been pressed
- lastDisplayTimer = millis();
- if (optionSelect == 1) { // if we are adjusting Zone 1
- triggerLow[0] = (triggerLow[0] - 25);
- }
- else if (optionSelect == 2) { // if we are adjusting Zone 2
- triggerLow[1] = (triggerLow[1] - 25);
- }
- else if (optionSelect == 3) { // if we are adjusting Zone 3
- triggerLow[2] = (triggerLow[2] - 25);
- }
- else if (optionSelect == 4) { // if we are adjusting Zone 4
- triggerLow[3] = (triggerLow[3] - 25);
- }
- }
- lastButtonState3 = buttonState3;
- lcd.clear();
- }
- }
- else if (itemSelect == 3) { // if we are adjusting settings
- buttonState2 = (digitalRead(button2));
- buttonState3 = (digitalRead(button3));
- if (buttonState2 !=
- lastButtonState2) { // if the right button has been pressed
- if (buttonState2 == LOW) { // if the right button has been pressed
- lastDisplayTimer = millis();
- if (optionSelect == 1) { // if we are adjusting Zone 1
- watchDog[0] = (watchDog[0] + 60000);
- }
- else if (optionSelect == 2) { // if we are adjusting Zone 2
- watchDog[1] = (watchDog[1] + 60000);
- }
- else if (optionSelect == 3) { // if we are adjusting Zone 3
- watchDog[2] = (watchDog[2] + 60000);
- }
- else if (optionSelect == 4) { // if we are adjusting Zone 4
- watchDog[3] = (watchDog[3] + 60000);
- }
- }
- lastButtonState2 = buttonState2;
- lcd.clear();
- }
- if (buttonState3 !=
- lastButtonState3) { // if the left button has been pressed
- if (buttonState3 == LOW) { // if the left button has been pressed
- lastDisplayTimer = millis();
- if (optionSelect == 1) { // if we are adjusting Zone 1
- watchDog[0] = (watchDog[0] - 60000);
- }
- else if (optionSelect == 2) { // if we are adjusting Zone 2
- watchDog[1] = (watchDog[1] - 60000);
- }
- else if (optionSelect == 3) { // if we are adjusting Zone 3
- watchDog[2] = (watchDog[2] - 60000);
- }
- else if (optionSelect == 4) { // if we are adjusting Zone 4
- watchDog[3] = (watchDog[3] - 60000);
- }
- }
- lastButtonState3 = buttonState3;
- lcd.clear();
- }
- }
- else if (itemSelect == 5) { // if we are disabling/enabling the zone
- buttonState2 = (digitalRead(button1));
- buttonState3 = (digitalRead(button3));
- if (buttonState2 !=
- lastButtonState2) { // if the right button has been pressed
- if (buttonState2 == LOW) { // if the right button has been pressed
- lastDisplayTimer = millis();
- if (optionSelect == 1) { // if we are adjusting Zone 1
- if (zoneActive[0]) {
- zoneActive[0] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[0]) {
- zoneActive[0] = true;
- faultFlash[0] = false;
- itemSelect = 0;
- }
- }
- else if (optionSelect == 2) { // if we are adjusting Zone 2
- if (zoneActive[1]) {
- zoneActive[1] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[1]) {
- zoneActive[1] = true;
- faultFlash[1] = false;
- itemSelect = 0;
- }
- }
- else if (optionSelect == 3) { // if we are adjusting Zone 3
- if (zoneActive[2]) {
- zoneActive[2] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[2]) {
- zoneActive[2] = true;
- faultFlash[2] = false;
- itemSelect = 0;
- }
- }
- else if (optionSelect == 4) { // if we are adjusting Zone 4
- if (zoneActive[3]) {
- zoneActive[3] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[3]) {
- zoneActive[3] = true;
- faultFlash[3] = false;
- itemSelect = 0;
- }
- }
- }
- lastButtonState2 = buttonState2;
- }
- if (buttonState3 !=
- lastButtonState3) { // if the left button has been pressed
- if (buttonState3 == LOW) { // if the left button has been pressed
- lastDisplayTimer = millis();
- if (zoneActive[0]) {
- zoneActive[0] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[0]) {
- zoneActive[0] = true;
- faultFlash[0] = false;
- itemSelect = 0;
- }
- }
- else if (optionSelect == 2) { // if we are adjusting Zone 2
- if (zoneActive[1]) {
- zoneActive[1] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[1]) {
- zoneActive[1] = true;
- faultFlash[1] = false;
- itemSelect = 0;
- }
- }
- else if (optionSelect == 3) { // if we are adjusting Zone 3
- if (zoneActive[2]) {
- zoneActive[2] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[2]) {
- zoneActive[2] = true;
- faultFlash[2] = false;
- itemSelect = 0;
- }
- }
- else if (optionSelect == 4) { // if we are adjusting Zone 4
- if (zoneActive[3]) {
- zoneActive[3] = false;
- itemSelect = 0;
- }
- else if (!zoneActive[3]) {
- zoneActive[3] = true;
- faultFlash[3] = false;
- itemSelect = 0;
- }
- }
- lastButtonState3 = buttonState3;
- }
- }
- }
- void displayMenu() {
- if (menuOn) { // if the display is supposed to be on
- lcd.display(); // turn the display on
- lcd.backlight();
- if (optionSelect != lastOptionSelect) {
- lcd.clear();
- lastOptionSelect = optionSelect;
- }
- else if (itemSelect != lastItemSelect) {
- lcd.clear();
- lastItemSelect = itemSelect;
- }
- switch (optionSelect) {
- case 0:
- lcd.home();
- lcd.print("Zone1: ");
- lcd.print(sensor[0]);
- if (zoneActive[0]) {
- lcd.setCursor(10, 0);
- lcd.print(" ACTIVE");
- }
- else if (!zoneActive[0]) {
- lcd.setCursor(10, 0);
- lcd.print(" OFF");
- }
- lcd.setCursor(0, 1);
- lcd.print("Zone2: ");
- lcd.print(sensor[1]);
- if (zoneActive[1]) {
- lcd.setCursor(10, 1);
- lcd.print(" ACTIVE");
- }
- else if (!zoneActive[1]) {
- lcd.setCursor(10, 1);
- lcd.print(" OFF");
- }
- lcd.setCursor(0, 2);
- lcd.print("Zone3: ");
- lcd.print(sensor[2]);
- if (zoneActive[2]) {
- lcd.setCursor(10, 2);
- lcd.print(" ACTIVE");
- }
- else if (!zoneActive[2]) {
- lcd.setCursor(10, 2);
- lcd.print(" OFF");
- }
- lcd.setCursor(0, 3);
- lcd.print("Zone4: ");
- lcd.print(sensor[3]);
- if (zoneActive[3]) {
- lcd.setCursor(10, 3);
- lcd.print(" ACTIVE");
- }
- else if (!zoneActive[3]) {
- lcd.setCursor(10, 3);
- lcd.print(" OFF");
- }
- break;
- case 1:
- if (itemSelect == 0 && zoneActive[0] == true) {
- lcd.home();
- lcd.print(" -ZONE 1 ACTIVE-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 0 && zoneActive[0] == false) {
- lcd.home();
- lcd.print(" -ZONE 1 DISABLED-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 4 && zoneActive[0] == false) {
- lcd.home();
- lcd.print(" -ZONE 1 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: DISABLED");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO:");
- lcd.setCursor(0, 3);
- lcd.print(" ACTIVATE ZONE");
- }
- else if (itemSelect == 1) {
- lcd.home();
- lcd.print(" -ZONE 1 TRIGGER-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[0]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trigger: ");
- lcd.setCursor(8, 3);
- lcd.print(triggerLow[0]);
- }
- else if (itemSelect == 2) {
- lcd.home();
- lcd.print(" -ZONE 1 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[0]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trig Set:");
- lcd.setCursor(0, 3);
- lcd.print(" < ");
- lcd.print(triggerLow[0]);
- lcd.print(" >");
- }
- else if (itemSelect == 3) {
- lcd.home();
- lcd.print(" -ZONE 1 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Watchdog Timer:");
- lcd.setCursor(0,2);
- lcd.print("< ");
- lcd.print(watchDog[0] / 60000);
- lcd.print(" >");
- lcd.setCursor(0,3);
- lcd.print(" Minutes");
- }
- else if (itemSelect == 4 && zoneActive[0] == true) {
- lcd.home();
- lcd.print(" -ZONE 1 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: ACTIVE");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO");
- lcd.setCursor(0, 3);
- lcd.print(" DISABLE ZONE");
- }
- break;
- case 2:
- if (itemSelect == 0 && zoneActive[1] == true) {
- lcd.home();
- lcd.print(" -ZONE 2 ACTIVE-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 0 && zoneActive[1] == false) {
- lcd.home();
- lcd.print(" -ZONE 2 DISABLED-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 4 && zoneActive[1] == false) {
- lcd.home();
- lcd.print(" -ZONE 2 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: DISABLED");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO:");
- lcd.setCursor(0, 3);
- lcd.print(" ACTIVATE ZONE");
- }
- else if (itemSelect == 1) {
- lcd.home();
- lcd.print(" -ZONE 2 TRIGGER-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[1]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trigger: ");
- lcd.setCursor(8, 3);
- lcd.print(triggerLow[1]);
- }
- else if (itemSelect == 2) {
- lcd.home();
- lcd.print(" -ZONE 2 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[1]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trig Set:");
- lcd.setCursor(0, 3);
- lcd.print(" < ");
- lcd.print(triggerLow[1]);
- lcd.print(" >");
- }
- else if (itemSelect == 3) {
- lcd.home();
- lcd.print(" -ZONE 2 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Watchdog Timer:");
- lcd.setCursor(0,2);
- lcd.print("< ");
- lcd.print(watchDog[1] / 60000);
- lcd.print(" >");
- lcd.setCursor(0,3);
- lcd.print(" Minutes");
- }
- else if (itemSelect == 4 && zoneActive[1] == true) {
- lcd.home();
- lcd.print(" -ZONE 2 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: ACTIVE");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO");
- lcd.setCursor(0, 3);
- lcd.print(" DISABLE ZONE");
- }
- break;
- case 3:
- if (itemSelect == 0 && zoneActive[2] == true) {
- lcd.home();
- lcd.print(" -ZONE 3 ACTIVE-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 0 && zoneActive[2] == false) {
- lcd.home();
- lcd.print(" -ZONE 3 DISABLED-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 4 && zoneActive[2] == false) {
- lcd.home();
- lcd.print(" -ZONE 3 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: DISABLED");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO:");
- lcd.setCursor(0, 3);
- lcd.print(" ACTIVATE ZONE");
- }
- else if (itemSelect == 1) {
- lcd.home();
- lcd.print(" -ZONE 3 TRIGGER-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[2]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trigger: ");
- lcd.setCursor(8, 3);
- lcd.print(triggerLow[2]);
- }
- else if (itemSelect == 2) {
- lcd.home();
- lcd.print(" -ZONE 3 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[2]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trig Set:");
- lcd.setCursor(0, 3);
- lcd.print(" < ");
- lcd.print(triggerLow[2]);
- lcd.print(" >");
- }
- else if (itemSelect == 3) {
- lcd.home();
- lcd.print(" -ZONE 3 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Watchdog Timer:");
- lcd.setCursor(0,2);
- lcd.print("< ");
- lcd.print(watchDog[2] / 60000);
- lcd.print(" >");
- lcd.setCursor(0,3);
- lcd.print(" Minutes");
- }
- else if (itemSelect == 4 && zoneActive[2] == true) {
- lcd.home();
- lcd.print(" -ZONE 3 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: ACTIVE");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO");
- lcd.setCursor(0, 3);
- lcd.print(" DISABLE ZONE");
- }
- break;
- case 4:
- if (itemSelect == 0 && zoneActive[3] == true) {
- lcd.home();
- lcd.print(" -ZONE 4 ACTIVE-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 0 && zoneActive[3] == false) {
- lcd.home();
- lcd.print(" -ZONE 4 DISABLED-");
- lcd.setCursor(0, 1);
- lcd.print("< >");
- lcd.setCursor(0, 2);
- lcd.print(" Press DOWN To See/");
- lcd.setCursor(0, 3);
- lcd.print(" Set Details");
- }
- else if (itemSelect == 4 && zoneActive[3] == false) {
- lcd.home();
- lcd.print(" -ZONE 4 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: DISABLED");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO:");
- lcd.setCursor(0, 3);
- lcd.print(" ACTIVATE ZONE");
- }
- else if (itemSelect == 1) {
- lcd.home();
- lcd.print(" -ZONE 4 TRIGGER-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[3]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trigger: ");
- lcd.setCursor(8, 3);
- lcd.print(triggerLow[3]);
- }
- else if (itemSelect == 2) {
- lcd.home();
- lcd.print(" -ZONE 4 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Moisture Level: ");
- lcd.print(sensor[3]);
- lcd.setCursor(0, 2);
- lcd.print(" Moisture Trig Set:");
- lcd.setCursor(0, 3);
- lcd.print(" < ");
- lcd.print(triggerLow[3]);
- lcd.print(" >");
- }
- else if (itemSelect == 3) {
- lcd.home();
- lcd.print(" -ZONE 4 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" Watchdog Timer:");
- lcd.setCursor(0,2);
- lcd.print("< ");
- lcd.print(watchDog[3] / 60000);
- lcd.print(" >");
- lcd.setCursor(0,3);
- lcd.print(" Minutes");
- }
- else if (itemSelect == 4 && zoneActive[3] == true) {
- lcd.home();
- lcd.print(" -ZONE 4 SETTING-");
- lcd.setCursor(0, 1);
- lcd.print(" ZONE: ACTIVE");
- lcd.setCursor(0, 2);
- lcd.print(" PRESS DOWN TO");
- lcd.setCursor(0, 3);
- lcd.print(" DISABLE ZONE");
- }
- break;
- }
- if ((unsigned long)(millis() - lastDisplayTimer) >= displayTimer) {
- menuOn = false;
- }
- } else if (!menuOn) { // if the display is supposed to be off
- lcd.noDisplay(); // turn the display off
- lcd.noBacklight();
- optionSelect = 0; // back to front screen
- itemSelect = 0;
- }
- if ((buttonState1 == 0) && (!menuOn)) {
- menuOn = true;
- lastDisplayTimer = millis();
- optionSelect = 0; // back to front screen
- itemSelect = 0;
- lastButtonState1 = buttonState1;
- }
- }
- void loop() {
- // put your main code here, to run repeatedly:
- readButtons();
- zoneLoop();
- displayMenu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement