I'm hoping you fine people could help me out, I've been stuck on this for DAYS and am getting NOWHERE!
I am using;
Arduino UNO
3 shift registers (two 74hc165 and one 74hc595)- pins 4,5,6,7 (165) pins- 10,11,12 (595)
Adafruit OLED display (128x64) 1306 (pins a5, a4, 5v)
12 inputs (pulled to LOW through optocouplers to shift register)
6 outputs (turn on relays)
3 push buttons directly to pins 3,8,13 for a menu- input_pullups
This project is for a multi-zoned HVAC system. it calls from 4 stats and turns on HVAC system (Heat, Cool, Fan) , with 4 different zone actuators.
I have a relief damper with pressure control that modulates per static pressure, per zone.
I am trying to control multiple zones using a push button menu; to set the modulation per zone for static relief. (up, down, page select buttons)
My problem is; all the code is working fine until I add in all the comparator inputs. (It will work with a few but not all) There are 46 different input scenarios.
I have isolated just the display and control buttons in the code- it works (menu works perfectly)
I have isolated just the inputs using serial monitor in the code- it works (inserted dummy input byte numbers as a bypass while taking out shift register code)
I add in the "if" and "if else" statements with the display (the 46 scenarios) and it freezes.
I have tried:
different power sources (laptop and desktop power supply through VIN)
adding delays
switch menu input buttons from HIGH to LOW
THOUGHTS:
How can I index my scenarios better to simplify the commands and reduce computing power?
What can I do to make the code work better- I can not change the footprint of my PCB so changing hardware or pins isn't an option.
Here is my code:
#include <Adafruit_SH110X.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define i2c_Address 0x3c //0x3D
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int staticPin = A0;
//int sensorValue = 0;
//int outputValue = 0;
int force = 155;
int minPressure = 630;
int maxPressure = 635;
const int actuator = 9;
const int numReadings = 10; //used to take an average of the static pressure reading
int readings[numReadings];
int readIndex = 0;
int total = 0;
int average = 0;
// Define Connections to 74HC165
// PL pin 1
int load = 7;
// CE pin 15
int clockEnablePin = 4;
// Q7 pin 7
int dataIn = 5;
// CP pin 2
int clockIn = 6;
// Define Connections to 74HC595
// ST_CP pin 12
const int latchPin = 10;
// SH_CP pin 11
const int clockPin = 11;
// DS pin 14
const int dataPin = 12;
byte incoming = 0;
byte incoming2 = 0;
int byteOutput;
/////////////////////////////////////////////////////////////////////////////////////////////////
int upButton = 3; //INPUT_PULLUP button attached to digital pin 3
int downButton = 8; //INPUT_PULLUP button attached to digital pin 4
int modeButton = 13; //INPUT_PULLUP button attached to digital pin 5
int buttonPressCount = 0;
int buttonState = 0;
int prevButtonState = 0;
int flipThru = 0;
int staticPressureSafetyMax = 635;
int staticPressureSafetyMin = 625;
int staticPressure1stMax = 0;
//int staticPressure1stMin = 625;
int staticPressure2ndMax = 0;
//int staticPressure2ndMin = 625;
int staticPressure3rdMax = 0;
//int staticPressure3rdMin = 625;
bool flag1 = LOW; //one time flag variable to just use an if statement once - scrolls thrus sensor readouts
bool flag2 = LOW; //one time flag variable to just use an if statement once - used for setpoint
bool flag3 = LOW; //one time flag variable to just use an if statement once - used for setpoint
bool flag4 = LOW; //one time flag variable to just use an if statement once - voltage display
bool flag5 = LOW; // a flag to overide the output to the actuator
bool flag6 = LOW;
bool flag7 = LOW;
bool flag8 = LOW;
bool everyFloor; //used variable to switch between
bool lowFloor; //used variable to switch between
bool midFloor; //used variable to switch between
bool upFloor; //used variable to switch between
bool status1st; //furnace floor call status display
bool status2nd; //furnace floor call status display
bool status3rd; //furnace floor call status display
bool heatStatus; // status for display
bool coolStatus; // status for display
bool fanStatus; // status for display
unsigned long currentTime = 0; //variable named to millis
unsigned long prevTime = 0; //button debounce
unsigned long prevTime2 = 0; //actual flip thru timer
unsigned long prevTime3 = 0; //delay to return to flip thru after a button has been pressed
unsigned long prevTime4 = 0; //delay for the static actuator to move
unsigned long prevTime5 = 0; // delay for the shift registers
unsigned long prevTime6 = 0;
unsigned long prevTime7 = 0;
unsigned long prevTime8 = 0;
int cycleDelay = 1000; //button debounce
int cycleDelay2 = 4000; //actual flip thru timer
int cycleDelay3 = 5000; //delay to return to flip thru after a button has been pressed
int cycleDelay4 = 3000; ////delay for the static actuator to move
int cycleDelay5 = 1000; // delay for the shift registers
int cycleDelay6 = 60000;
int cycleDelay7 = 60000;
int cycleDelay8 = 60000;
void display00() {
display.clearDisplay();
display.display();
if (heatStatus) {
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(30, 25);
display.print("HEAT");
} else if (coolStatus) {
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(30, 25);
display.print("COOL");
} else if (fanStatus) {
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(40, 25);
display.print("FAN");
} else {
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
display.setCursor(25, 25);
display.print("NO CALL");
}
display.display(); // actually display all of the above
}
void display0() {
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.print("3rd floor ");
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(65, 0);
if (status3rd) {
display.print("Enabled");
} else {
display.print("Disabled");
}
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 25);
display.print("2nd floor ");
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(65, 25);
if (status2nd) {
display.print("Enabled");
} else {
display.print("Disabled");
}
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 50);
display.print("1st floor ");
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(65, 50);
if (status1st) {
display.print("Enabled");
} else {
display.print("Disabled");
}
display.display(); // actually display all of the above
}
void display1() {
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(9, 3);
display.print("Safe Static = ");
display.print(staticPressureSafetyMax);
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(40, 25);
display.print(average);
display.display(); // actually display all of the above
}
void display2() {
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(28, 5);
display.print("1st relief ");
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(45, 25);
display.print(staticPressure1stMax);
display.display(); // actually display all of the above
}
void display3() {
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(28, 5);
display.print("2nd Relief ");
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(45, 25);
display.print(staticPressure2ndMax);
display.display(); // actually display all of the above
}
void display4() {
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(28, 5);
display.print("3rd Relief ");
display.setTextSize(3);
display.setTextColor(SH110X_WHITE);
display.setCursor(45, 25);
display.print(staticPressure3rdMax);
display.display(); // actually display all of the above
}
void setup() {
//Serial.begin(9600);
display.begin(i2c_Address, true);
display.display();
delay(1000);
display.clearDisplay(); //command that clears the buffer
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(modeButton, INPUT_PULLUP);
buttonPressCount = 1;
//////////////////////////////////////////////////////
pinMode(staticPin, INPUT);
pinMode(actuator, OUTPUT);
// 74HC165 pins
pinMode(load, OUTPUT);
pinMode(clockEnablePin, OUTPUT);
pinMode(clockIn, OUTPUT);
pinMode(dataIn, INPUT);
// 74HC595 pins
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
for (int thisReading = 0; thisReading < numReadings; thisReading++) { // used to take an average of the static pressure reading
readings[thisReading] = 0;
}
//////////////////////////test////////////////////////
status1st = LOW;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = LOW;
}
void loop() {
/*total = total - readings[readIndex]; // MAKE A TIMER THAT DOES THIS AVERAGE TAKE
readings[readIndex] = analogRead(staticPin);
total = total + readings[readIndex];
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
readIndex = 0;
}
average = total / numReadings;
// Serial.println(average);
delay(2);*/
currentTime = millis();
buttonState = digitalRead(modeButton);
if (currentTime - prevTime >= cycleDelay) {
if (buttonState != prevButtonState) {
buttonPressCount++;
prevTime = currentTime;
}
}
prevButtonState = buttonState;
//digitalRead(upButton);
//digitalRead(downButton);
//digitalRead(modeButton);
if (currentTime - prevTime2 >= cycleDelay2) {
prevTime2 = currentTime;
flipThru = flipThru + 1;
}
if (flipThru >= 3) {
flipThru = 0;
}
if ((flipThru == 1) && (!flag1) && (!flag3)) {
flag1 = HIGH;
display0();
everyFloor = LOW;
upFloor = LOW;
midFloor = LOW;
lowFloor = LOW;
}
if ((flipThru == 2) && (flag1) && (!flag3)) {
flag1 = LOW;
display00();
everyFloor = LOW;
upFloor = LOW;
midFloor = LOW;
lowFloor = LOW;
}
if ((buttonPressCount == 2) && (!flag2)) {
everyFloor = HIGH;
flag2 = HIGH;
display1();
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
if ((buttonPressCount == 3) && (flag2)) {
everyFloor = LOW;
lowFloor = HIGH;
flag2 = LOW;
display2();
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
if ((buttonPressCount == 4) && (!flag2)) {
lowFloor = LOW;
midFloor = HIGH;
flag2 = HIGH;
display3();
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
if ((buttonPressCount == 5) && (flag2)) {
midFloor = LOW;
upFloor = HIGH;
display4();
flag2 = LOW;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
if (buttonPressCount >= 6) {
buttonPressCount = 1;
upFloor = LOW;
//display0();
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
if (currentTime - prevTime3 >= cycleDelay3) {
flag3 = LOW;
}
//if ((currentTime - prevTime >= cycleDelay) && (everyFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(upButton) == 0) && (everyFloor)) {
staticPressureSafetyMax = staticPressureSafetyMax + 1; //Setpoint++ (increases the variable)
display1();
prevTime = currentTime; //button debounce
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (everyFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(downButton) == 0) && (everyFloor)) {
staticPressureSafetyMax = staticPressureSafetyMax - 1; //Setpoint-- (decreases the variable)
display1();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (lowFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(upButton) == 0) && (lowFloor)) {
staticPressure1stMax = staticPressure1stMax + 1; //Setpoint++ (increases the variable)
display2();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (lowFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(downButton) == 0) && (lowFloor)) {
staticPressure1stMax = staticPressure1stMax - 1; //Setpoint-- (decreases the variable)
display2();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (midFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(upButton) == 0) && (midFloor)) {
staticPressure2ndMax = staticPressure2ndMax + 1; //Setpoint++ (increases the variable)
display3();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (midFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(downButton) == 0) && (midFloor)) {
staticPressure2ndMax = staticPressure2ndMax - 1; //Setpoint-- (decreases the variable)
display3();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (upFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(upButton) == 0) && (upFloor)) {
staticPressure3rdMax = staticPressure3rdMax + 1; //Setpoint++ (increases the variable)
display4();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
// }
//if ((currentTime - prevTime >= cycleDelay) && (upFloor)) { //Reads everytime the set Interval is reached
if ((digitalRead(downButton) == 0) && (upFloor)) {
staticPressure3rdMax = staticPressure3rdMax - 1; //Setpoint-- (decreases the variable)
display4();
prevTime = currentTime;
flag3 = HIGH; // flag that goes with delay to flip thru
prevTime3 = currentTime; // delay to return to flip thru scroll
}
//}
//////////////////////////////////////////SAFETY/////////////////////////////////////////////////////////
if ((average > staticPressureSafetyMax) && (force < 254) && (currentTime - prevTime4 >= cycleDelay4)) {
force = force + 5;//actutor output signal
flag5 = HIGH;//override the single floor actuator output
prevTime4 = currentTime;//delay for surges
}
else {
}
if ((average < staticPressureSafetyMin) && (force > 0) && (currentTime - prevTime4 >= cycleDelay4) && (flag5)) {
force = force - 5;//actutor output signal
prevTime4 = currentTime;//delay for surges
flag5 = LOW;//override the single floor actuator output
}
else {
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
if ((currentTime - prevTime5 >= cycleDelay5)){//1 second delay before inputing and outputing shiftristers
prevTime5 = currentTime;
//analogWrite(actuator, force);
//Serial.print("act%");
//Serial.println(force);
// Read optocouplers
// Write pulse to load pin
digitalWrite(load, LOW);
delay(5);
digitalWrite(load, HIGH);
delay(5);
// Get data from 74HC165's
digitalWrite(clockIn, HIGH);
digitalWrite(clockEnablePin, LOW);
incoming = shiftIn(dataIn, clockIn, LSBFIRST);
incoming2 = shiftIn(dataIn, clockIn, LSBFIRST);
digitalWrite(clockEnablePin, HIGH);
// Print to serial monitor
//byte incoming = B11011111;
//byte incoming2 = B11111111;
Serial.print("Shift ic 1:\r\n");
Serial.println(incoming, DEC);
Serial.print("Shift ic 2:\r\n");
Serial.println(incoming2, DEC);
// Serial.print("Combined DEC:\r\n");
//Serial.println(combinedBytes, DEC);
// Write to relays
// ST_CP LOW to keep relays from changing while reading serial data
digitalWrite(latchPin, LOW);
// Shift out the bits
shiftOut(dataPin, clockPin, MSBFIRST, byteOutput);
// ST_CP HIGH change relays
digitalWrite(latchPin, HIGH);
// delay(100);
}
/*//////////////////////////////as soon as i add comparators
if(incoming == 127){//upstairs heat 1
// byteOutput = B00011001;
status1st = LOW;
status2nd = LOW;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("Upstairs Heat \r\n");
//if(!flag5){
// force = staticPressure3rdMax;
}
else if(incoming == B10111111){//upstairs cool 2)
byteOutput = B00011010;
status1st = LOW;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("Upstairs Cool \r\n");
}
else if(incoming == B11011111){//upstairs fan 3)
byteOutput = B00011100;
status1st = LOW;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("Upstairs fan \r\n");
}
else if(incoming == B11101111){//middle heat 4)
byteOutput = B00101001;
status1st = LOW;
status2nd = HIGH;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("middle heat \r\n");
}
else if(incoming == B11110111){//middle cool 5)
byteOutput = B00101010;
status1st = LOW;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("middle cool \r\n");
}
else if(incoming == B11111011){//middle fan 6)
byteOutput = B00101100;
status1st = LOW;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("middle fan \r\n");
}
else if(incoming == B11111101){//lower heat 7
byteOutput = B00110001;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("lower heat \r\n");
}
else if(incoming == B11111110){//lower cool 8
byteOutput = B00110010;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("lower cool \r\n");
}
else if(incoming == B01101111){//upper & middle heat 9
byteOutput = B00001001;
status1st = LOW;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & middle heat \r\n");
}
else if(incoming == B10110111){//upper & middle cool 10
byteOutput = B00001010;
status1st = LOW;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & middle cool \r\n");
}
else if(incoming == B11011011){//upper & middle fan 11
byteOutput = B00001100;
status1st = LOW;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & middle fan \r\n");
}
else if(incoming == B01101101){//upper & middle & lower heat 12
byteOutput = B00000001;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & middle & lower heat \r\n");
}
else if(incoming == B10110110){//upper & middle & lower cool 13
byteOutput = B00000010;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & middle & lower cool \r\n");
}
else if((incoming == B11011011) && (incoming2 == B01111111)){//upper & middle & lower fan 14
byteOutput = B00000100;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & middle & lower fan \r\n");
}
else if(incoming == B01111101){//upper & lower heat 15
byteOutput = B00010001;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & lower heat \r\n");
if(!flag5){
force = 0;
}
}
else if(incoming == B10111110){//upper & lower cool 16
byteOutput = B00010010;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & lower cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111011) && (incoming2 == B01111111)){//upper & lower fan 17
byteOutput = B00010100;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & lower fan \r\n");
if(!flag5){
force = 0;
}
}
else if(incoming == B11101101){//middle & lower heat 18
byteOutput = B00100001;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("middle & lower heat \r\n");
if(!flag5){
force = 0;
}
}
else if(incoming == B11110110){//middle & lower cool 19
byteOutput = B00100010;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("middle & lower cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111011) && (incoming2 == 01111111)){//middle & lower fan 20
byteOutput = B00100100;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("middle & lower fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B01111111) && (incoming2 == B10111111)){//upper & BLE heat 21
byteOutput = B00010001;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & BLE heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B10111111) && (incoming2 == B11011111)){//upper & BLE cool 22
byteOutput = B00010010;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & BLE cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11011111) && (incoming2 == B11101111)){//upper & BLE fan 23
byteOutput = B00010100;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & BLE fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11101111) && (incoming2 == B10111111)){//middle & BLE heat 24
byteOutput = B00100001;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("middle & BLE heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11110111) && (incoming2 == B11011111)){//middle & BLE cool 25
byteOutput = B00100010;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("middle & BLE cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111011) && (incoming2 == B11101111)){//middle & BLE fan 26
byteOutput = B00100100;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("middle & BLE fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111101) && (incoming2 == B10111111)){//lower & BLE heat 27
byteOutput = B00110001;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("lower & BLE heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111110) && (incoming2 == B11011111)){//lower & BLE cool 28
byteOutput = B00110010;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("lower & BLE cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B01101101) && (incoming2 == B10111111)){//upper & middle & BLE & lower heat 29
byteOutput = B00000001;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & middle & BLE & lower heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B10110110) && (incoming2 == B11011111)){//upper & middle & BLE & lower cool 30
byteOutput = B00000010;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & middle & BLE & lower cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11011011) && (incoming2 == B01101111)){//upper & middle & BLE & lower fan 31
byteOutput = B00000100;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & middle & BLE & lower fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B01101111) && (incoming2 == B10111111)){//upper & middle & BLE heat 32
byteOutput = B00000001;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & middle & BLE heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B10110111) && (incoming2 == B11011111)){//upper & middle & BLE cool 33
byteOutput = B00000010;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & middle & BLE cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11011011) && (incoming2 == B11101111)){//upper & middle & BLE fan 34
byteOutput = B00000100;
status1st = HIGH;
status2nd = HIGH;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & middle & BLE fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11101101) && (incoming2 == B10111111)){//middle & BLE & lower heat 35
byteOutput = B00100001;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("middle & BLE & lower heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11110110) && (incoming2 == B11011111)){//middle & BLE & lower cool 36
byteOutput = B00100010;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("middle & BLE & lower cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111011) && (incoming2 == B01101111)){//middle & BLE & lower fan 37
byteOutput = B00100100;
status1st = HIGH;
status2nd = HIGH;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("middle & BLE & lower fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B01111101) && (incoming2 == B10111111)){//upper & BLE & lower heat 38
byteOutput = B00010001;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("upper & BLE & lower heat \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B10111110) && (incoming2 == B11011111)){//upper & BLE & lower cool 39
byteOutput = B00010010;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("upper & BLE & lower cool \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11011111) && (incoming2 == B01101111)){//upper & BLE & lower fan 40
byteOutput = B00010100;
status1st = HIGH;
status2nd = LOW;
status3rd = HIGH;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("upper & BLE & lower fan \r\n");
if(!flag5){
force = 0;
}
}
else if((incoming == B11111111) && (incoming2 == B11111111)){// NO CALL NO CALL NO CALL 41
byteOutput = B00000000;
status1st = LOW;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = LOW;
flag5 = LOW;
force = 0;
Serial.print("No Call\r\n");
}
else if((incoming == B11111111) && (incoming2 == B01111111)){ //lower fan 42
byteOutput = B00110100;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("lower fan \r\n");
if(!flag5){
force = staticPressure1stMax;
}
}
else if((incoming == B11111111) && (incoming2 == B10111111)){//BLE heat 43
byteOutput = B00110001;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = HIGH;
coolStatus = LOW;
fanStatus = LOW;
Serial.print("BLE heat \r\n");
if(!flag5){
force = staticPressure1stMax;
}
}
else if((incoming == B11111111) && (incoming2 == B11011111)){//BLE cool 44
byteOutput = B00110010;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = HIGH;
fanStatus = LOW;
Serial.print("BLE cool \r\n");
if(!flag5){
force = staticPressure1stMax;
}
}
else if((incoming == B11111111) && (incoming2 == B11101111)){//BLE fan 45
byteOutput = B00110100;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("BLE fan \r\n");
if(!flag5){
force = staticPressure1stMax;
}
}
else if((incoming == B11111111) && (incoming2 == B01101111)){//lower & BLE fan 46
byteOutput = B00110100;
status1st = HIGH;
status2nd = LOW;
status3rd = LOW;
heatStatus = LOW;
coolStatus = LOW;
fanStatus = HIGH;
Serial.print("lower & BLE fan \r\n");
if(!flag5){
force = staticPressure1stMax;
}
}
//delay(2000);
*/
/////////////////////////////////////////////////////////////////
staticPressureSafetyMin = staticPressureSafetyMax - 3;
}
/*
staticPressure1stMin = staticPressure1stMax - 3;
staticPressure2ndMin = staticPressure2ndMax - 3;
staticPressure3rdMin = staticPressure3rdMax - 3;*/