Interrupts slowing program????

I had this program working good and as soon as I added in the interrupt code to read the flow sensors, the button have to be HELD down in order to have them function... The program is very slow to react, some of the LCD functions are lagging to (like a text blink when the memory is erased). If I'm not mistaken, the interrupts should only affect pins 2&3 on the Uno.

Any ideas on what would fix this?

Your code is ...? We can't just guess what the problem is.

My code: (I have not cleaned it up yet, I just have been working on getting this thing working, so please go easy on me!!)

Also, I had to remove some of the code so I could post it.

// Library
#include <EEPROM.h>

// Pins
int pressurePin = A0;
int menuswitchPin = 4;
int selectswitchPin = 5;
int logswitchPin = 6;
int resetswitchPin = 7;

// Values
int menuval;
int menuval2;
int selectval;
int selectval2;
int logval;
int logval2;
int resetval;
int resetval2;
int menubuttonState;
int menubuttonPresses = 0;
int logbuttonState;
int logbuttonPresses = 1;
int Agaddr = 0;
int Araddr = 1;
int Asaddr = 2;
int Bgaddr = 3;
int Braddr = 4;
int Bsaddr = 5;
int Cgaddr = 6;
int Craddr = 7;
int Csaddr = 8;
int Dgaddr = 9;
int Draddr = 10;
int Dsaddr = 11;
int Agpm = 0;
int Ares = 0;
int Astat = 0;
int Bgpm = 0;
int Bres = 0;
int Bstat = 0;
int Cgpm = 0;
int Cres = 0;
int Cstat = 0;
int Dgpm = 0;
int Dres = 0;
int Dstat = 0;
unsigned long gpm;
unsigned long pressure;
volatile int NbTopsFan1;
volatile int NbTopsFan2;
int Calc1;
int Calc2;
int Calc3;
int hallsensor1 = 2;
int hallsensor2 = 3;

void rpm1 ()
{
  NbTopsFan1++;
}

void rpm2 ()
{
  NbTopsFan2++;
}

void setup()
{
  Serial.begin(9600);
  backlightOff();
  pinMode(menuswitchPin, INPUT);
  pinMode(selectswitchPin, INPUT);
  pinMode(logswitchPin, INPUT);
  pinMode(resetswitchPin, INPUT);
  pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
  pinMode(hallsensor2, INPUT);
  attachInterrupt(0, rpm1, RISING); //and the interrupt is attached mube pin 2 
  attachInterrupt(1, rpm2, RISING); // must be pin 3

menubuttonState = digitalRead(menuswitchPin);
logbuttonState = digitalRead(logswitchPin);

}

void loop()
{
//GPM Stuff!!!
  NbTopsFan1 = 0;   //Set NbTops to 0 ready for calculations
  NbTopsFan2 = 0;
  sei();      //Enables interrupts
  delay (1000);   //Wait 1 second
  cli();      //Disable interrupts
  Calc1 = ((NbTopsFan1/7.5)*0.2642); //7.5Q, = flow rate in l/min
  Calc2 = ((NbTopsFan2/7.5)*0.2642);
  Calc3 = (Calc1 + Calc2);
  
  
//Math Section
int pressureLevel = analogRead(pressurePin);
pressureLevel = constrain(pressureLevel, 0, 892);
int pressure = (892 - pressureLevel) * .17;
gpm = (Calc3);
//pressure = (millis()/2000);

//Live Display Code  
if (menubuttonPresses != 1){
  if (menubuttonPresses != 2){
     selectLineOne();
     delay(100);
     Serial.print("               ");
     selectLineOne();
     Serial.print(gpm);
     goTo(3);
     Serial.print("GPM");
     goTo(7);
     Serial.print(pressure);
     goTo(10);
     Serial.print("PSI");
  }
}

//Menu System Code
if (menubuttonPresses == 0){
  selectLineTwo();
  delay(100);  
  Serial.print("Live View       ");
}
  //Menu Button Debounce
    menuval = digitalRead(menuswitchPin);
    delay(10);
    menuval2 = digitalRead(menuswitchPin);
      //Menu Button Counting
      if (menuval == menuval2){
        if (menuval != menubuttonState){
          if (menuval == LOW){
            menubuttonPresses++;
          }
        }
      }
    menubuttonState = menuval;
    if (menubuttonPresses == 3){
    menubuttonPresses = 0;
   }
   
//Log System Code
if (logbuttonPresses == 1){
  goTo(15);
  Serial.print("A");
  }
if (logbuttonPresses == 2){
  goTo(15);
  Serial.print("B");
  }
if (logbuttonPresses == 3){
  goTo(15);
  Serial.print("C");
  }
if (logbuttonPresses == 4){
  goTo(15);
  Serial.print("D");
}

  //Log Button Debounce
  logval  = digitalRead(logswitchPin);
  delay(10);
  logval2 = digitalRead(logswitchPin);
  if (logval == logval2){
    if (logval != logbuttonState){
      if (logval == LOW){
        logbuttonPresses++;
        if (logbuttonPresses == 2){
          goTo(15);
          Serial.print("B");
         }
        else if (logbuttonPresses == 3){
           goTo(15);
           Serial.print("C");
         }
         else if (logbuttonPresses == 4){
           goTo(15);
           Serial.print("D");
         }
      }
    }
  }
    logbuttonState = logval;
    if (logbuttonPresses == 5){
    logbuttonPresses = 1;
    }

//Record System Code
  //Select Button Debounce
    selectval = digitalRead(selectswitchPin);
    delay(10);
    selectval2 = digitalRead(selectswitchPin);
      //Record to Log Code
      if (selectval == selectval2){
         if (selectval == LOW){
           if (menubuttonPresses == 0 && logbuttonPresses == 1 && gpm > 1){
              Agpm = gpm;
              Ares = pressure;
              EEPROM.write(Agaddr, Agpm);
              EEPROM.write(Araddr, Ares);
              recordflash1();
            }
            else if(menubuttonPresses == 0 && logbuttonPresses == 2 && gpm > 1){
              Bgpm = gpm;
              Bres = pressure;
              EEPROM.write(Bgaddr, Bgpm);
              EEPROM.write(Braddr, Bres);
              recordflash1();
            }
     

//Memory System Code
           if (menubuttonPresses == 1 && logbuttonPresses == 1){
             selectLineOne();
             delay(100);
             Serial.print("Memory log     "); 
             selectLineTwo();
             delay(100);
             Serial.print("                ");
             goTo(16);
             Serial.print("G=");
             Agpm = EEPROM.read(Agaddr);
             Serial.print(Agpm);
             goTo(21);
             Serial.print("R=");
             Ares = EEPROM.read(Araddr);
             Serial.print(Ares);
             goTo(26);
             Serial.print("S=");
             Astat = EEPROM.read(Asaddr);
             Serial.print(Astat);
            }
            else if(menubuttonPresses == 1 && logbuttonPresses == 2){
             selectLineOne();
             delay(100);
             Serial.print("Memory log     ");
             selectLineTwo();
             delay(100);
             Serial.print("                ");
             goTo(16);
             Serial.print("G=");
             Bgpm = EEPROM.read(Bgaddr);
             Serial.print(Bgpm);
             goTo(21);
             Serial.print("R=");
             Bres = EEPROM.read(Braddr);
             Serial.print(Bres);
             goTo(26);
             Serial.print("S=");
             Bstat = EEPROM.read(Bsaddr);
             Serial.print(Bstat);
            }
            else if(menubuttonPresses == 1 && logbuttonPresses == 3){
             selectLineOne();
             delay(100);
             Serial.print("Memory log     ");
             selectLineTwo();
             delay(100);
             Serial.print("                ");
             goTo(16);
             Serial.print("G=");
             Cgpm = EEPROM.read(Cgaddr);
             Serial.print(Cgpm);
             goTo(21);
             Serial.print("R=");
             Cres = EEPROM.read(Craddr);
             Serial.print(Cres);
             goTo(26);
             Serial.print("S=");
             Cstat = EEPROM.read(Csaddr);
             Serial.print(Cstat);
            }
            else if(menubuttonPresses == 1 && logbuttonPresses == 4){
             selectLineOne();
             delay(100);
             Serial.print("Memory log     ");
             selectLineTwo();
             delay(100);
             Serial.print("                ");
             goTo(16);
             Serial.print("G=");
             Dgpm = EEPROM.read(Dgaddr);
             Serial.print(Dgpm);
             goTo(21);
             Serial.print("R=");
             Dres = EEPROM.read(Draddr);
             Serial.print(Dres);
             goTo(26);
             Serial.print("S=");
             Dstat = EEPROM.read(Dsaddr);
             Serial.print(Dstat);
            }

//Memory Clear System Code
if(menubuttonPresses == 2){
  selectLineOne();
  delay(100);
  Serial.print("Clear this   ");
  selectLineTwo();
  delay(100);
  Serial.print("log's memory?   ");
}

        
} // End

Sorry nick... I was having trouble posting the code because it was too long.

Why do this?

  sei();      //Enables interrupts
  delay (1000);   //Wait 1 second
  cli();      //Disable interrupts

... the button have to be HELD down in order to have them function...

For a second, perhaps?

That portion was copied from the original example code for the flow sensor. I suppose I can reduce that delay to less but then I'll be taking a smaller (and possibly less accurate) sample.

So are you saying I should use some other timing method for the sample length?

I'm not sure what you are trying to do here. I presume the delay is new, and that is what is causing the lengthy time to process button presses, because you are forcing it to do nothing for a second every time around the loop.

So are you saying I should use some other timing method for the sample length?

Yes. Something like, start a sample (ie. set NbTopsFan1 and NbTopsFan2 to zero) and and note the time (with millis()). Then when a second has elapsed, check the values. That gives you a second of samples, but meanwhile you are processing button presses etc.

Got it working perfectly after a few tries and a bit of debugging.

Thanks Nick!