Paul sometimes your little comments are enough to get the brain going in the right direction without giving away the answer. This is not one of those times...
I tried removing the delay from what I think is the interupt. It stopped working.
It currently works with the one delay but the buttons are still erratic.
this is what I tried instead of using a delay.
void checkflow()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
unsigned long currentMillis = millis();
//delay(1000);
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
cli(); //Disable interrupts
// block-style blinking cursor
lcd.cursor(0);
lcd.cursorTo(1,1);
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour
lcd.print (Calc, DEC); //Prints the number calculated above
lcd.print (" L/hour"); //Prints "L/hour" and returns a new line
}
lcd.cursorTo(2,1);
totaldispensed +=((float)Calc / 3600);
lcd.print ("total: ");
int intValue = (int)totaldispensed; // convert float PHValue to tricky int combination
float diffValue = totaldispensed - (float)intValue;
int anotherIntValue = (int)(diffValue * 1000.0);
lcd.print (intValue);
lcd.print (".");
lcd.print (anotherIntValue);
lcd.print ("L");
}
I didnt get any compile errors but it stopped counting.
What should i be looking at to rid myself of the last delay and to start figuring out why button presses sometimes skip around and sometimes have to hold the button down for a while to get it to recognize the press.