Mak'er Grow
Well-Known Member
For the rest following along...been a few crappy days...haven't gotten to any coding as of late, but will as soon as I can.
Now I think you meant PumpStart, but that very well could of been my typo...either way I will look into it and thanks for helping.PimpStart probably ain't helping. I will leave you to your devices.
//========================================================================================================================================
// USER SETTINGS FOR 16 TIMERS (4 RELAY BOARDS @ 4 RELAYS EACH)
// Use "army" time for settings...minus the "0"...example...09:00 (9am) = 9 as value....0 = Midnight/12:00am
// 00 to 23.
// Cannot do pm to am unless you reverse digitalRead(s) & digitalWrites for that Timer/Relay # and reverse times
// for ON/OFF, due to now setting an OFF Run Time instead of ON Run Time.
//
//----> Last edit = Jan 1, 2021.
//
//========================================================================================================================================
int L1_S = 7; //Starting @
int L1_E = 23; //Ending @
int P1_S = 1; //Every x minutes
int P1_R = 10; //For y seconds
int G1_D = 1; //Day to start
int G1_M = 1; //Month to start
int G1_Y = 2018; //Year to start
int G1_L = 60; //Grow for x days
int L2_S = 7; //Starting @
int L2_E = 23; //Ending @
int P2_S = 1; //Every x minutes
int P2_R = 10; //For y seconds
int G2_D = 1; //Day to start
int G2_M = 1; //Month to start
int G2_Y = 2018; //Year to start
int G2_L = 60; //Grow for x days
int L3_S = 7; //Starting @
int L3_E = 23; //Ending @
int P3_S = 1; //Every x minutes
int P3_R = 10; //For y seconds
int G3_D = 1; //Day to start
int G3_M = 1; //Month to start
int G3_Y = 2018; //Year to start
int G3_L = 60; //Grow for x days
int L4_S = 7; //Starting @
int L4_E = 23; //Ending @
int P4_S = 1; //Every x minutes
int P4_R = 10; //For y seconds
int G4_D = 1; //Day to start
int G4_M = 1; //Month to start
int G4_Y = 2018; //Year to start
int G4_L = 60; //Grow for x days
#include <TimeLib.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <UTFT.h>
#include <URTouch.h>
#include <avr/pgmspace.h>
#include <SPI.h>
#include <SD.h>
#include "BlueDot_BME280.h"
#include <avr/wdt.h>
#define FAN1_Q '1'
#define FAN2_Q '2'
#define FAN3_Q '3'
#define FAN4_Q '4'
#define FAN5_Q 'a'
#define FAN6_Q 'b'
#define FAN7_Q 'c'
#define FAN8_Q 'd'
#define FAN_Q 'f'
#define TIME_Q 'T'
#define DAY_Q 'D'
#define MONTH_Q 'M'
#define YEAR_Q 'Y'
#define hour_Q 'h'
#define minute_Q 'm'
#define second_Q 's'
#define read_Q 'r'
#define clrScrn_Q 'C'
#define reset_Q 'R'
#define preset_Q 'p'
#define misc_Q 'x'
#define menu_Q '?'
#define TCAADDR 0x70
static boolean isLongFormat = true;
extern uint8_t SmallFont[]; //40 Characters X 20 Lines (8x12 px)
extern uint8_t BigFont[]; //20 Characters X 15 Lines (16x16 px)
const char *MITY[13] = {"Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov"};
String D = "";
String C = "";
int Y = 2021;
String data = "";
double TempC;
double TempF;
String TempChoice = "C"; //"C" or "F"
int CurDay = 10;
BlueDot_BME280 bme280_i;
File myFile;
const int chipSelect = 4;
String fileName = "";
String Rx = "";
String tempRx = "";
String rxName = "";
String rxValue = "";
String varName = "";
String varValue = "";
String b1PlantName = "";
String b1LightStart = "";
String b1LightEnd = "";
String b1PumpStart = "";
String b1PumpRun = "";
String b2PlantName = "";
String b2LightStart = "";
String b2LightEnd = "";
String b2PumpStart = "";
String b2PumpRun = "";
String b3PlantName = "";
String b3LightStart = "";
String b3LightEnd = "";
String b3PumpStart = "";
String b3PumpRun = "";
String b4PlantName = "";
String b4LightStart = "";
String b4LightEnd = "";
String b4PumpStart = "";
String b4PumpRun = "";
int L_S = 0;
int L_E = 0;
int P_S = 0;
int P_R = 0;
int c1 = 0;
int c2 = 0;
int c3 = 0;
int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;
int fillIn = 0;
int Pg = 0;
int x, y;
int Bright = 0;
int zzz = 2000;
int resync = 0;
int rtcReads = 0;
int rtcPassed = 0;
int rtcFailed = 0;
int resyncFailed = 0;
//----------------------------------------------------------------------------------------------------------------------------
UTFT myGLCD(HX8347I, 38, 39, 40, 41);
URTouch myTouch( 6, 5, 4, 3, 2);
//----------------------------------------------------------------------------------------------------------------------------
//UTFT myGLCD(SSD1289, 38, 39, 40, 41); URTouch myTouch( 6, 5, 4, 3, 2); //Test display...broken.
void setup() {
Serial.begin(9600);
wdt_enable(WDTO_8S);
Wire.begin();
Serial.println("");
Serial.println("Looking for SD card...");
pinMode(SS, OUTPUT);
if (SD.begin(chipSelect))
{
Serial.print("Reading data.");
for (int B = 1; B <= 4; B++) {
Serial.println("");
fileName = "BOX" + String(B);
fileName = fileName + ".txt";
Serial.print(fileName);
varName = "";
varValue = "";
myFile = SD.open(fileName);
if (myFile) {readFile(B);} myFile.close();} Serial.println(""); Serial.println("Done.");} else {Serial.println("No card found...Using Default values.");}
Read_RTC();
myGLCD.InitLCD(0); //0=Portrait 1=Landscape (default) ??=Rotate 90' (90/180/270)
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
myGLCD.clrScr();
pinMode(14, OUTPUT); //RELAY 1 #1 - Lights
pinMode(16, OUTPUT); //RELAY 1 #2 - Water Pump
pinMode(15, OUTPUT); //RELAY 1 #3 - Lights
pinMode(17, OUTPUT); //RELAY 1 #4 - Water Pump
pinMode(8, OUTPUT); //RELAY 2 #1 - Lights
pinMode(10, OUTPUT); //RELAY 2 #2 - Water Pump
pinMode(9, OUTPUT); //RELAY 2 #3 - Lights
pinMode(11, OUTPUT); //RELAY 2 #4 - Water Pump
pinMode(18, OUTPUT); //RELAY 3 #1 - Fan1
pinMode(19, OUTPUT); //RELAY 3 #2 - Fan2
pinMode(20, OUTPUT); //RELAY 3 #3 - Fan3
pinMode(21, OUTPUT); //RELAY 3 #4 - Fan4
pinMode(A12, OUTPUT); //RELAY 3 #5 - Fan5
pinMode(A13, OUTPUT); //RELAY 3 #6 - Fan6
pinMode(A14, OUTPUT); //RELAY 3 #7 - Fan7
pinMode(A15, OUTPUT); //RELAY 3 #8 - Fan8
listMenu();
fanCheck();
}
void loop() {
showPg(0);
resyncRTC();
portCheck();
lightCheck("L1", 14, 4, 75);
TempCheck(1, 3, 110);
HumiCheck(1, 3, 140);
pumpCheck("P1", 16, 3, 175);
lightCheck("L2", 15, 123, 75);
TempCheck(2, 123, 110);
HumiCheck(2, 123, 140);
pumpCheck("P2", 17, 123, 175);
lightCheck("L3", 8, 3, 200);
TempCheck(3, 3, 235);
HumiCheck(3, 3, 265);
pumpCheck("P3", 10, 3, 300);
lightCheck("L4", 9, 123, 200);
TempCheck(4, 123, 235);
HumiCheck(4, 123, 265);
pumpCheck("P4", 11, 123, 300);
touchCheck();
}
void Date(int h, int v) {
D = month();
D = D + String(" ");
if (day() < 10) {
D = D + "0" + String(day());
} else {
D = D + String(day());
}
D = D + " " + String(year());
myGLCD.setColor(255, 255, 255);
myGLCD.setFont(BigFont);
myGLCD.print(" " + D + " ", h, v);
}
void Clock(int h, int v) {
C = hour();
C = C + String(":");
//if (hour() < 1) {C = String("12") + String(":");} else {if (hour() > 12) {if (hour() < 22) {C = String(" ") + String(hour() - 12) + String(":");} else {C = String(hour() - 12) + String(":");}} else {C = (hour()) + String(":");}}
if (minute() < 10) {
C = C + String("0") + String(minute()) + String(":");
} else {
C = C + String(minute()) + String(":");
}
if (second() < 10) {
C = C + String("0") + String(second());
} else {
C = C + String(second());
}
myGLCD.setColor(255, 255, 255);
myGLCD.setFont(BigFont);
myGLCD.print(" " + C + " ", h, v);
}
void resyncRTC() {
if (year() != Y) {delay(5000); Read_RTC();}
if (resync == 0) {if (minute() == 0) {if (second() == 0) {Read_RTC(); resync = 1; resyncFailed = resyncFailed + 1;}}}
if (resync == 1) {if (minute() == 1) {if (second() == 1) {resync = 0;}}}
}
void listMenu() {
Serial.println();
Serial.println("1-4 & a-d Turns ON/OFF 8x relay board number you use.");
Serial.println("f = Show current fan status.");
Serial.println("T = Input all 10 digits. eg T1536620390 = Sept 10 2018 @ 10:59:50pm");
Serial.println("D = Add 1 DAY.");
Serial.println("M = Add 1 MONTH.");
Serial.println("Y = Add 1 YEAR.");
Serial.println("h = Add 1 hour.");
Serial.println("m = Add 1 minute.");
Serial.println("s = Add 1 second.");
Serial.println("r = Read current value.");
Serial.println("c = Clears/Refreshes LCD screen.");
Serial.println("R = Reset to Jan 01 1970.");
Serial.println("p = Preset value @ 1603726000 = Oct 26 2020 @ 15:26:40");
Serial.println("x = setTime(14, 59, 00, 26, 10, 2020)");
Serial.println(" hh, mm, ss, DD, MM, YYYY)");
Serial.println("? = Show input list/info.");
}
void portCheck() {
if (Serial.available() > 0)
{ char Rx = Serial.read();
if (Rx == TIME_Q) {setTime(Serial.parseInt());}
if (Rx == DAY_Q) {setTime(now() + 86400);}
if (Rx == MONTH_Q) {if (String(month()) == "1" or String(month()) == "3" or String(month()) == "5" or String(month()) == "7" or String(month()) == "8" or String(month()) == "10" or String(month()) == "12") {setTime(now() + 2678400);} else {if (String(month()) == "4" or String(month()) == "6" or String(month()) == "9" or String(month()) == "11") {setTime(now() + 2592000);} else {if (String(month()) == "2") {setTime(now() + 2419200);}}}}
if (Rx == YEAR_Q) {setTime(now() + (86400 * 365));}
if (Rx == hour_Q) {setTime(now() + 3600);}
if (Rx == minute_Q) {setTime(now() + 60);}
if (Rx == second_Q) {setTime(now() + 1);}
if (Rx == read_Q) {Serial.println(String(now()));}
if (Rx == clrScrn_Q) {myGLCD.clrScr();}
if (Rx == reset_Q) {setTime(0);}
if (Rx == preset_Q) {setTime(1603726000);} //T1603726000}
if (Rx == misc_Q) {setTime(14, 59, 00, 26, 10, 2020);}
if (Rx == FAN1_Q) {Fan(1);}
if (Rx == FAN2_Q) {Fan(2);}
if (Rx == FAN3_Q) {Fan(3);}
if (Rx == FAN4_Q) {Fan(4);}
if (Rx == FAN5_Q) {Fan(5);}
if (Rx == FAN6_Q) {Fan(6);}
if (Rx == FAN7_Q) {Fan(7);}
if (Rx == FAN8_Q) {Fan(8);}
if (Rx == FAN_Q) {fanCheck();}
if (Rx == menu_Q) {listMenu();}
}
}
void lightCheck(String Light, int Pin, int h, int v) {
if ((Light + "_S") == "L1_S") {L_S = L1_S;}
if ((Light + "_E") == "L1_E") {L_E = L1_E;}
if ((Light + "_S") == "L2_S") {L_S = L2_S;}
if ((Light + "_E") == "L2_E") {L_E = L2_E;}
if ((Light + "_S") == "L3_S") {L_S = L3_S;}
if ((Light + "_E") == "L3_E") {L_E = L3_E;}
if ((Light + "_S") == "L4_S") {L_S = L4_S;}
if ((Light + "_E") == "L4_E") {L_E = L4_E;}
if (hour() < L_S or hour() > L_E - 1 && digitalRead(Pin) == 0) {digitalWrite(Pin, 1);}
if (hour() >= L_S && hour() <= L_E - 1 && digitalRead(Pin) == 1) {digitalWrite(Pin, 0);}
if (digitalRead(Pin) == 0) {myGLCD.setColor(0, 255, 0);} else {myGLCD.setColor(255, 0, 0);}
myGLCD.print(String(L_S) + " - " + String(L_E), h, v);
myGLCD.setColor(255, 255, 255);
}
void pumpCheck(String Pump, int Pin, int h, int v) {
if ((Pump + "_S") == "P1_S") {P_S = P1_S;}
if ((Pump + "_R") == "P1_R") {P_R = P1_R;}
if ((Pump + "_S") == "P2_S") {P_S = P2_S;}
if ((Pump + "_R") == "P2_R") {P_R = P2_R;}
if ((Pump + "_S") == "P3_S") {P_S = P3_S;}
if ((Pump + "_R") == "P3_R") {P_R = P3_R;}
if ((Pump + "_S") == "P4_S") {P_S = P4_S;}
if ((Pump + "_R") == "P4_R") {P_R = P4_R;}
if ((digitalRead(Pin) == 1) && (minute() % P_S == 0) && (second() < P_R)) {digitalWrite(Pin, 0);}
if ((digitalRead(Pin) == 0) && (second() > P_R - 1)) {digitalWrite(Pin, 1);}
if (digitalRead(Pin) == 0) {myGLCD.setColor(0, 255, 0);} else {myGLCD.setColor(255, 0, 0);}
myGLCD.print(String(P_R) + " - " + String(P_S), h, v);
myGLCD.setColor(255, 255, 255);
}
void tcaselect(uint8_t i) {
if (i > 7) return;
Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
bme280_i.parameter.communication = 0;
bme280_i.parameter.I2CAddress = 0x76; //Choose I2C Address
bme280_i.parameter.sensorMode = 0b11; //Choose sensor mode
bme280_i.parameter.IIRfilter = 0b100; //Setup for IIR Filter
bme280_i.parameter.humidOversampling = 0b101; //Setup Humidity Oversampling
bme280_i.parameter.tempOversampling = 0b101; //Setup Temperature Ovesampling
bme280_i.parameter.pressOversampling = 0b101; //Setup Pressure Oversampling
bme280_i.init();
}
double TempCheck(int pin, int h, int v) {
double Temp;
tcaselect(pin);
if (TempChoice = "C") {
myGLCD.print(" " + String(bme280_i.readTempC(), 0) + " C ", h, v);
} else {
myGLCD.print(" " + String(bme280_i.readTempF(), 0) + " F ", h, v);
}
}
double HumiCheck(int pin, int h, int v) {
double Temp;
tcaselect(pin);
myGLCD.print(" " + String(bme280_i.readHumidity(), 0) + " % ", h, v);
}
void Read_RTC() {
tcaselect(0);
setSyncProvider(RTC.get);
rtcReads = rtcReads + 1;
if (timeStatus() != timeSet) {Serial.println(""); Serial.println("RTC read falled."); rtcFailed = rtcFailed + 1; if (rtcFailed == 5) {showPg(99);}} //Failed read.
if (timeStatus() == timeSet) {Serial.println(""); Serial.println("RTC read successfully."); rtcPassed = rtcPassed + 1;} //Good read.
}
void readFile(int BOX) {
while (myFile.available()) {
char Rx = myFile.read();
if (String(Rx) == "=") { ;} else {if (String(Rx) == "!") { ;} else {if (String(Rx) == " ") { ;} else {if (Rx == 10) { ;} else {if (Rx == 13) { ;} else {tempRx += Rx;}}}}}
if (String(Rx) == "=") {rxName = tempRx; varName = "b" + String(BOX); varName = String(varName) + String(rxName); tempRx = ""; Rx = ""; Serial.print(".");}
if (String(Rx) == "!") {rxValue = tempRx; varValue = rxValue; tempRx = ""; Rx = ""; Serial.print(".");}
if (String(varName) == "b1PlantName") {b1PlantName = varValue;}
if (String(varName) == "b1LightStart") {L1_S = varValue.toInt();}
if (String(varName) == "b1LightEnd") {L1_E = varValue.toInt();}
if (String(varName) == "b1PumpStart") {P1_S = varValue.toInt();}
if (String(varName) == "b1PumpRun") {P1_R = varValue.toInt();}
if (String(varName) == "b2PlantName") {b2PlantName = varValue;}
if (String(varName) == "b2LightStart") {L2_S = varValue.toInt();}
if (String(varName) == "b2LightEnd") {L2_E = varValue.toInt();}
if (String(varName) == "b2PumpStart") {P2_S = varValue.toInt();}
if (String(varName) == "b2PumpRun") {P2_R = varValue.toInt();}
if (String(varName) == "b3PlantName") {b3PlantName = varValue;}
if (String(varName) == "b3LightStart") {L3_S = varValue.toInt();}
if (String(varName) == "b3LightEnd") {L3_E = varValue.toInt();}
if (String(varName) == "b3PumpStart") {P3_S = varValue.toInt();}
if (String(varName) == "b3PumpRun") {P3_R = varValue.toInt();}
if (String(varName) == "b4PlantName") {b4PlantName = varValue;}
if (String(varName) == "b4LightStart") {L4_S = varValue.toInt();}
if (String(varName) == "b4LightEnd") {L4_E = varValue.toInt();}
if (String(varName) == "b4PumpStart") {P4_S = varValue.toInt();}
if (String(varName) == "b4PumpRun") {P4_R = varValue.toInt();}
}
}
void box(int c1, int c2, int c3, int x1, int y1, int x2, int y2, int fillIn) {
myGLCD.setColor(c1, c2, c3);
if (fillIn == 0) {myGLCD.drawRect(x1, y1, x2, y2);} else {myGLCD.fillRect(x1, y1, x2, y2);}
}
void touchCheck() {
if (myTouch.dataAvailable()) {
myGLCD.clrScr();
myTouch.read();
x = myTouch.getX();
y = myTouch.getY();
if ((x >= 0) && (x <=65) && (y >= 0) && (y <= 50)) {showPg(99);}
if ((x >= 0) && (x <=65) && (y >= 50) && (y <= 320)) {showPg(5);}
if ((y >= 1) && (y <= 120)) {if ((x >= 65) && (x <= 190)) {box(255, 0, 0, 1, 71, 120, 195, 1); showPg(1);}
if ((x >= 191) && (x <= 320)) {box(255, 0, 0, 1, 196, 120, 318, 1); showPg(3);}}
else {if ((x >= 65) && (x <= 190)) {box(255, 0, 0, 121, 71, 238, 195, 1); showPg(2);}
if ((x >= 191) && (x <= 320)) {box(255, 0, 0, 121, 196, 238, 318, 1); showPg(4);}}
}
}
}
void showPg(int Pg) {
basicPg();
x = 0;
y = 0;
if (Pg == 0) {
box(255, 255, 255, 1, 71, 120, 195, 0); //BOX 1 - Top Left frame
box(255, 255, 255, 121, 71, 238, 195, 0); //BOX 2 - Top Right frame
box(255, 255, 255, 1, 196, 120, 318, 0); //BOX 3 - Bottom Left frame
box(255, 255, 255, 121, 196, 238, 318, 0); //BOX 4 - Bottom Right frame
}
if (Pg == 1) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
myGLCD.print("BOX 1", CENTER, 75);
myGLCD.print(b1PlantName, 10, 100);
if (L1_E - L1_S > 12) {myGLCD.print("Flower Cycle", 10, 125);} else {myGLCD.print("Veg Cycle", 10, 125);}
if (CurDay < 10) {myGLCD.print("Day 0" + String(CurDay) + " of " + String(G1_L), 10, 150);} else {myGLCD.print("Day " + String(CurDay) + " of " + String(G1_L), 10, 150);}
delay(zzz);
myGLCD.clrScr();
}
if (Pg == 2) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
myGLCD.print("BOX 2", CENTER, 75);
myGLCD.print(b2PlantName, 10, 100);
if (L2_E - L2_S > 12) {myGLCD.print("Flower Cycle ", 10, 125);} else {myGLCD.print("Veg Cycle ", 10, 125);}
if (CurDay < 10) {myGLCD.print("Day 0" + String(CurDay) + " of " + String(G2_L), 10, 150);} else {myGLCD.print("Day " + String(CurDay) + " of " + String(G2_L), 10, 150);}
delay(zzz);
myGLCD.clrScr();
}
if (Pg == 3) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
myGLCD.print("BOX 3", CENTER, 75);
myGLCD.print(b3PlantName, 10, 100);
if (L3_E - L3_S > 12) {myGLCD.print("Flower Cycle ", 10, 125);} else {myGLCD.print("Veg Cycle ", 10, 125);}
if (CurDay < 10) {myGLCD.print("Day 0" + String(CurDay) + " of " + String(G3_L), 10, 150);} else {myGLCD.print("Day " + String(CurDay) + " of " + String(G3_L), 10, 150);}
delay(zzz);
myGLCD.clrScr();
}
if (Pg == 4) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
myGLCD.print("BOX 4", CENTER, 75);
myGLCD.print(b4PlantName, 10, 100);
if (L4_E - L4_S > 12) {myGLCD.print("Flower Cycle ", 10, 125);} else {myGLCD.print("Veg Cycle ", 10, 125);}
if (CurDay < 10) {myGLCD.print("Day 0" + String(CurDay) + " of " + String(G4_L), 10, 150);} else {myGLCD.print(" Day " + String(CurDay) + " of " + String(G4_L), 10, 150);}
delay(zzz);
myGLCD.clrScr();
}
if (Pg == 5) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255); /*
//Serial.print("Reads ");
//Serial.println(rtcReads);
myGLCD.print("Reads:", 10, 75);
myGLCD.print(String(rtcReads), 200, 75);
//Serial.print("Passed Reads ");
//Serial.println(rtcPassed);
myGLCD.print("Passed", 10, 100);
myGLCD.print(String(rtcPassed), 200, 100);
//Serial.print("Failed Reads ");
//Serial.println(rtcFailed);
myGLCD.print("Failed", 10, 125);
myGLCD.print(String(rtcFailed), 200, 125);
//Serial.print("Resync Fail ");
//Serial.println(resyncFailed);
myGLCD.print("Resync Fail", 10, 150);
myGLCD.print(String(resyncFailed), 200, 150); */
buttons();
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
Clock(CENTER, 50);
Serial.println(x);
Serial.println(y);
if (myTouch.dataAvailable()) {
myTouch.read();
x = myTouch.getX();
y = myTouch.getY();
Serial.println(x);
Serial.println(y);
//delay(zzz*3);
myGLCD.clrScr();}
else
{wdt_reset(); showPg(5);}
}
if (Pg == 10) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
myGLCD.clrScr();
}
if (Pg == 99) {
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
Serial.print("RESETTING");
myGLCD.print("RESETTING", CENTER, 90);
Serial.println("---------");
myGLCD.print("---------", CENTER, 110);
for (int x=0; x<=8; x++) {Serial.println(8-x); myGLCD.print(" ", CENTER, 150); delay(100); myGLCD.print(String(8-x), CENTER, 150); delay(900);}
myGLCD.clrScr();
}
}
void basicPg() {
box(255, 255, 255, 0, 0, 239, 319, 0); //Main outside frame
box(255, 255, 255, 1, 1, 238, 70, 0); //Top center frame
myGLCD.setColor(0, 255, 0);
myGLCD.setFont(BigFont);
myGLCD.print("T0YB0X", CENTER, 6);
myGLCD.setColor(0, 0, 0);
myGLCD.drawLine(2, 25, 237, 25);
Date(CENTER, 30);
Clock(CENTER, 50);
wdt_reset();
}
void buttons() {
if (digitalRead(18) == "OFF") {box(255, 0, 0, 10, 175, 50, 215, 1);} else {box(0, 255, 0, 10, 175, 50, 215, 1);}
myGLCD.print("1", 22, 187);
if (digitalRead(19) == "OFF") {box(255, 0, 0, 55, 175, 95, 215, 1);} else {box(0, 255, 0, 55, 175, 95, 215, 1);}
myGLCD.print("2", 67, 187);
if (digitalRead(20) == "OFF") {box(255, 0, 0, 100, 175, 140, 215, 1);} else {box(0, 255, 0, 100, 175, 140, 215, 1);}
myGLCD.print("3", 112, 187);
if (digitalRead(21) == "OFF") {box(255, 0, 0, 145, 175, 185, 215, 1);} else {box(0, 255, 0, 145, 175, 185, 215, 1);}
myGLCD.print("4", 157, 187);
if (digitalRead(A12) == "OFF") {box(255, 0, 0, 190, 175, 230, 215, 1);} else {box(0, 255, 0, 190, 175, 230, 215, 1);}
myGLCD.print("5", 202, 187);
if (digitalRead(A13) == "OFF") {box(255, 0, 0, 10, 225, 50, 265, 1);} else {box(0, 255, 0, 10, 225, 50, 265, 1);}
myGLCD.print("6", 22, 237);
if (digitalRead(A14) == "OFF") {box(255, 0, 0, 55, 225, 95, 265, 1);} else {box(0, 255, 0, 55, 225, 95, 265, 1);}
myGLCD.print("7", 67, 237);
if (digitalRead(A15) == "OFF") {box(255, 0, 0, 100, 225, 140, 265, 1);} else {box(0, 255, 0, 100, 225, 140, 265, 1);}
myGLCD.print("8", 112, 237);
box(255, 0, 0, 145, 225, 185, 265, 0);
myGLCD.print("9", 157, 237);
box(255, 0, 0, 190, 225, 230, 265, 0);
myGLCD.print("0", 202, 237);
box(255, 255, 255, 10, 275, 228, 309, 0);
myGLCD.print("E X I T", CENTER, 285);
}
void fanCheck() {
if (digitalRead(18) == 0) {Serial.println("Fan 1 = OFF");} else {Serial.println("Fan 1 = ON");}
if (digitalRead(19) == 0) {Serial.println("Fan 2 = OFF");} else {Serial.println("Fan 2 = ON");}
if (digitalRead(20) == 0) {Serial.println("Fan 3 = OFF");} else {Serial.println("Fan 3 = ON");}
if (digitalRead(21) == 0) {Serial.println("Fan 4 = OFF");} else {Serial.println("Fan 4 = ON");}
if (digitalRead(A12) == 0) {Serial.println("Fan 5 = OFF");} else {Serial.println("Fan 5 = ON");}
if (digitalRead(A13) == 0) {Serial.println("Fan 6 = OFF");} else {Serial.println("Fan 6 = ON");}
if (digitalRead(A14) == 0) {Serial.println("Fan 7 = OFF");} else {Serial.println("Fan 7 = ON");}
if (digitalRead(A15) == 0) {Serial.println("Fan 8 = OFF");} else {Serial.println("Fan 8 = ON");}
}
void Fan(int f) {
Serial.print("Fan ");
Serial.print(f);
if (f == 1) {if (digitalRead(18) == 0) {digitalWrite(18, 1); Serial.println(" ON");} else {digitalWrite(18, 0); Serial.println(" OFF");}}
if (f == 2) {if (digitalRead(19) == 0) {digitalWrite(19, 1); Serial.println(" ON");} else {digitalWrite(19, 0); Serial.println(" OFF");}}
if (f == 3) {if (digitalRead(20) == 0) {digitalWrite(20, 1); Serial.println(" ON");} else {digitalWrite(20, 0); Serial.println(" OFF");}}
if (f == 4) {if (digitalRead(21) == 0) {digitalWrite(21, 1); Serial.println(" ON");} else {digitalWrite(21, 0); Serial.println(" OFF");}}
if (f == 5) {if (digitalRead(A12) == 0) {digitalWrite(A12, 1); Serial.println(" ON");} else {digitalWrite(A12, 0); Serial.println(" OFF");}}
if (f == 6) {if (digitalRead(A13) == 0) {digitalWrite(A13, 1); Serial.println(" ON");} else {digitalWrite(A13, 0); Serial.println(" OFF");}}
if (f == 7) {if (digitalRead(A14) == 0) {digitalWrite(A14, 1); Serial.println(" ON");} else {digitalWrite(A14, 0); Serial.println(" OFF");}}
if (f == 8) {if (digitalRead(A15) == 0) {digitalWrite(A15, 1); Serial.println(" ON");} else {digitalWrite(A15, 0); Serial.println(" OFF");}}
}