¿¿¿¿OLED display and pushbutton menu MELTDOWN?Please help!

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;*/


I set up a simulation for probing.

I noticed when I removed the shift registers, your display and buttons work. I can MODE around and UP/DOWN. With the shift registers, one button works once, then the display goes away. I think the logic for the inputs is causing the outage.

diagram.json from the wokwi simulation
{
  "version": 1,
  "author": "Anonymous maker",
  "editor": "wokwi",
  "parts": [
    {
      "type": "wokwi-arduino-nano",
      "id": "nano",
      "top": -2.8,
      "left": 1.3,
      "rotate": 270,
      "attrs": {}
    },
    {
      "type": "board-ssd1306",
      "id": "oled1",
      "top": 41.54,
      "left": 144.23,
      "attrs": { "i2cAddress": "0x3c" }
    },
    { "type": "wokwi-74hc165", "id": "sr1", "top": -58.8, "left": -90.56, "attrs": {} },
    { "type": "wokwi-74hc595", "id": "sr2", "top": 104.4, "left": -90.56, "attrs": {} },
    { "type": "wokwi-vcc", "id": "vcc1", "top": -152.84, "left": -192, "attrs": {} },
    { "type": "wokwi-gnd", "id": "gnd1", "top": 201.6, "left": -19.8, "attrs": {} },
    {
      "type": "wokwi-pushbutton",
      "id": "btn1",
      "top": -109,
      "left": 48,
      "attrs": { "color": "green" }
    },
    {
      "type": "wokwi-pushbutton",
      "id": "btn2",
      "top": -157,
      "left": 48,
      "attrs": { "color": "green" }
    },
    {
      "type": "wokwi-pushbutton",
      "id": "btn3",
      "top": 121.4,
      "left": 57.6,
      "attrs": { "color": "green" }
    },
    {
      "type": "wokwi-text",
      "id": "text1",
      "top": -153.6,
      "left": 124.8,
      "attrs": { "text": "UP" }
    },
    {
      "type": "wokwi-text",
      "id": "text2",
      "top": -96,
      "left": 124.8,
      "attrs": { "text": "DOWN" }
    },
    {
      "type": "wokwi-text",
      "id": "text3",
      "top": 163.2,
      "left": 67.2,
      "attrs": { "text": "MODE" }
    },
    { "type": "wokwi-74hc165", "id": "sr3", "top": -58.8, "left": -176.96, "attrs": {} },
    {
      "type": "wokwi-led",
      "id": "led1",
      "top": 203.2,
      "left": -63,
      "rotate": 180,
      "attrs": { "color": "red" }
    },
    {
      "type": "wokwi-led",
      "id": "led2",
      "top": 203.2,
      "left": -82.2,
      "rotate": 180,
      "attrs": { "color": "red" }
    },
    {
      "type": "wokwi-led",
      "id": "led3",
      "top": 203.2,
      "left": -101.4,
      "rotate": 180,
      "attrs": { "color": "red" }
    },
    {
      "type": "wokwi-led",
      "id": "led4",
      "top": 203.2,
      "left": -120.6,
      "rotate": 180,
      "attrs": { "color": "red" }
    },
    {
      "type": "wokwi-led",
      "id": "led5",
      "top": 203.2,
      "left": -139.8,
      "rotate": 180,
      "attrs": { "color": "red" }
    },
    {
      "type": "wokwi-led",
      "id": "led6",
      "top": 203.2,
      "left": -159,
      "rotate": 180,
      "attrs": { "color": "red" }
    }
  ],
  "connections": [
    [ "oled1:GND", "nano:GND.1", "black", [ "v0" ] ],
    [ "nano:5V", "oled1:VCC", "red", [ "h0" ] ],
    [ "oled1:SCL", "nano:A5", "green", [ "v0" ] ],
    [ "nano:A4", "oled1:SDA", "green", [ "h0" ] ],
    [ "vcc1:VCC", "sr1:VCC", "red", [ "v38.4", "h96" ] ],
    [ "vcc1:VCC", "sr2:VCC", "red", [ "v220.8", "h96" ] ],
    [ "gnd1:GND", "sr2:GND", "black", [ "v-19.2", "h-9.6" ] ],
    [ "gnd1:GND", "sr1:GND", "black", [ "v-220.8", "h-9.6" ] ],
    [ "sr1:PL", "nano:7", "green", [ "v9.6" ] ],
    [ "sr1:CE", "nano:4", "green", [ "v-8.4", "h76.8", "v84.4" ] ],
    [ "sr1:Q7", "nano:5", "green", [ "h28.8", "v1.2" ] ],
    [ "sr1:CP", "nano:6", "green", [ "v0" ] ],
    [ "sr2:STCP", "nano:10", "green", [ "v0" ] ],
    [ "sr2:SHCP", "nano:11", "green", [ "v0" ] ],
    [ "sr2:DS", "nano:12", "green", [ "v0" ] ],
    [ "nano:GND.2", "btn1:2.l", "black", [ "h-19.2", "v-67.2" ] ],
    [ "nano:GND.2", "btn2:2.l", "black", [ "h-19.2", "v-115.2" ] ],
    [ "nano:GND.2", "btn3:1.l", "black", [ "h-19.2", "v144" ] ],
    [ "btn3:2.r", "nano:13", "green", [ "h9.8", "v-38.2" ] ],
    [ "btn1:1.l", "nano:8", "green", [ "h-28.8", "v153.6" ] ],
    [ "btn2:1.l", "nano:3", "green", [ "h-19.2", "v211.2" ] ],
    [ "vcc1:VCC", "sr3:VCC", "red", [ "v38.4", "h9.6" ] ],
    [ "gnd1:GND", "sr3:GND", "black", [ "v-220.8", "h-96" ] ],
    [ "gnd1:GND", "led1:C", "black", [ "v0", "h-28.8" ] ],
    [ "gnd1:GND", "led2:C", "black", [ "v0", "h-48" ] ],
    [ "gnd1:GND", "led3:C", "black", [ "v0", "h-57.6" ] ],
    [ "gnd1:GND", "led4:C", "black", [ "v0", "h-86.4" ] ],
    [ "gnd1:GND", "led5:C", "black", [ "v0", "h-105.6" ] ],
    [ "gnd1:GND", "led6:C", "black", [ "v0", "h-115.2" ] ],
    [ "sr2:Q0", "led1:A", "green", [ "v-18", "h-28.8", "v86.4", "h57.6" ] ],
    [ "sr2:Q1", "led2:A", "green", [ "v28.8", "h19.2" ] ],
    [ "sr2:Q2", "led3:A", "green", [ "v38.4", "h-9.6" ] ],
    [ "sr2:Q3", "led4:A", "green", [ "v19.2", "h-28.8" ] ],
    [ "sr2:Q4", "led5:A", "green", [ "v48", "h-67.2" ] ],
    [ "sr2:Q5", "led6:A", "green", [ "v57.6", "h-96" ] ]
  ],
  "dependencies": {}
}

Thank you for your reply. Are you saying the logic from the shift registers or the logic from the up, down, mode buttons may not work? if you remove the push buttons from the scene, i can get the read out from from the shift registers using a simulation of button inputs and using serial monitor. I do receive different readouts with different inputs. Its when both scenarios are combined display goes out. Any suggestions on a change of logic, or a direction I can take to use for indexing for less computing maybe? im fairly new to coding, and ready to give up. Thanks again.

Referring to the simulation... I pasted your code, then placed the devices according to your sketch. As I added devices, I gave your sketch a roll.... with OLED, then with buttons, your sketch worked - I could see the OLED change as I adjusted mode and up/down in each mode. Once I put the shift registers in, the simulation started failing, showing the "0" but then just a blank OLED...

BUT... now, even when I remove all the registers, the simulation does the "0 then blank screen" thing (I probably fat-fingered some code or the devices in the simulation... I will re-make it. and try again.

[edit]
I got the simulation back to working again...

This is a memory issue. The simulator gets strange when I add as little as a character to Serial.print();

and by the way, this is an awesome simulation website. thank you for showing me this. i never knew i could mod my code on the fly and simulate. i must be getting old

i only get a couple of hours a day before the family gets home to work on my hobbies. you believe removing all serial.prints from code may help? i will definitely be messing around now at work with my app "probing".

Not removing... just moving...

Moving data into flash memory with PROGMEM (read about this) and the Serial.print(F()); (<-- notice the F - also read about this) can move data into memory not used by programs (programs do not run in flash memory).

Moving redundant code and variables into external, independent functions helps by moving variables from global (uses memory for the life of the program) to local (memory is used only for the life of the function, and returned to the program to be shared).

The Uno (and Nano) have very little memory for making things work once an OLED is introduced. I believe 1k of program memory is taken for the OLED screen buffer, out of 2k SRAM of Uno/Nano data memory.

A Mega2560 has 16k SRAM (Uno/Nano 2k), and should handle your sketch without issue. You can simulate that, too, on Wokwi. Unfortunately, Wokwi is not easy to edit on smart phone or tablet. Ask any question.

Thanks again for your valuable help and efforts building that circuit. I will give it another stab tomorrow. I will alter the code with the recommendations and report back.

This is the memory usage compiling for the Uno/Nano.

Sketch uses 16588 bytes (51%) of program storage space. Maximum is 32256 bytes.
Global variables use 802 bytes (39%) of dynamic memory, leaving 1246 bytes for local variables. Maximum is 2048 bytes.

This is for the Mega2560

Sketch uses 17310 bytes (6%) of program storage space. Maximum is 253952 bytes.
Global variables use 802 bytes (9%) of dynamic memory, leaving 7390 bytes for local variables. Maximum is 8192 bytes.

Big difference in memory remaining.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.