Analog sensor update more often.

Some help getting mpxPin A0 to update more often.

 //PSPS for use in Arduino IDE.             Corresponding ATMega328P-AU TQFP32 pin

int cutOut = 1;                               //31
int cutIn = 5;                                //32
int pumpPin = 6;                             //1
int solenoid = 4;                             // solenoid connected to digital pin 4 on arduino.
const int  buttonPinOn = 1;                    // the pin that the ON pushbutton is attached to
const int  buttonPinOff = 0;                   // the pin that the OFF pushbutton is attached to
int mpxVal = 0;
int mpxValBar = 0;
const int MIN_mpxPin= 0;                     //constraint stuff
const int MAX_mpxPin= 1023;                  //constraint stuff
const int MIN_mpxPinBar= 0;                     //constraint stuff
const int MAX_mpxPinBar= 7;                  //constraint stuff
int mpxPin = A0;                            //23 

// include the library code:  
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd (7,8,9,10,11,12);          //11RS,12E,13D4,14D5,15D6,16D7



// Variables will change:
int buttonPushCounterOn = 0;            // counter for the number of button presses
int buttonPushCounterOff = 0;           // counter for the number of button presses
int buttonStateOn = 0;                      // current state of the button
int buttonStateOff = 0;                     // current state of the button
int lastButtonStateOn = 0;                     // previous state of the On button
int lastButtonStateOff = 0;                  // previous state of the Off button */


//LED Stuff1of3 
int led = 13;                                //16



void setup(){
  pinMode(solenoid, OUTPUT);                // sets the digital pins as in/output
  pinMode(cutIn, INPUT);
  pinMode(cutOut, INPUT);
  pinMode(pumpPin, OUTPUT);
  pinMode(buttonPinOn, INPUT);
  pinMode(buttonPinOff, INPUT);

  //LED Stuff2of3
  pinMode(led, OUTPUT);

  //Serial Stuff1of2
  //Serial.begin(9600);

  lcd.begin(16,2);                          // set up the LCD's number of columns and rows:
  lcd.print("www.MISTFITZ.com");            // Print a message to the LCD.
  delay(4000);
  lcd.clear();
  lcd.setCursor(2,1);
  lcd.print("-S.ON");
  lcd.setCursor(10,1);
  lcd.print("-M.OFF");


  attachInterrupt(buttonPinOn, isr1 ,RISING);
  attachInterrupt(buttonPinOff, isr2 ,RISING); 
}
void isr1()
{ 
  buttonPushCounterOn+=1;
  if(buttonPushCounterOn > 60)buttonPushCounterOn =0; // rollover after 60.
  lcd.setCursor(1,1);
  lcd.print(" ");
  lcd.setCursor(0,1);
  lcd.print(buttonPushCounterOn,DEC);

}

void isr2()
{
  buttonPushCounterOff+=1;
  if(buttonPushCounterOff > 60)buttonPushCounterOff =0;   // rollover after 60.
  lcd.setCursor(9,1);
  lcd.print(" ");
  lcd.setCursor(8,1);
  lcd.print(buttonPushCounterOff,DEC);

}
void loop(){ 

  //Read the MPX sensor                                                                                         *******************************
  mpxVal = analogRead(mpxPin);

  //Do the PSI /Bar maths
  mpxVal = map(mpxVal*.98, MIN_mpxPin, MAX_mpxPin, 0,101);
  mpxVal = constrain(mpxVal*.98, 0, 101);
  mpxValBar = map(mpxVal*.98, MIN_mpxPin, MAX_mpxPin, 0,7);
  mpxValBar = constrain(mpxValBar*.98, 0, 7);


  //Serial Stuff2of2
  //Serial.println(mpxVal, DEC); // Display pressure value.
  //delay (400);


  // On/Off Pressure Selection Switches
  //ON LOGIChigh: If the "on" slide switch is HIGH (indicating we want on at 40) and the pressure is  40 or less the pump will turn on at 40.
  if (digitalRead(cutIn) == HIGH && mpxVal <= 40){
    digitalWrite(pumpPin, HIGH);
    digitalWrite(led, HIGH);
  }
  //ON LOGIClow: But if the "on" slide switch is LOW (indicating we want on at 80)and pressure is 50 or less the pump will turn on at 50.
  else if (digitalRead(cutIn) == LOW && mpxVal <= 50){
    digitalWrite(pumpPin, HIGH);
    digitalWrite(led, HIGH);
  }

  //OFF LOGIChigh: If the "off" slide switch is HIGH (indicating we want off at 60) and the pressure is 60 or greater the pump will turn on at 60.
  if (digitalRead(cutOut) == HIGH && mpxVal >= 60){
    digitalWrite(pumpPin, LOW);
    digitalWrite(led, LOW);
  }
  //OFF LOGIClow: If the "off" slide switch is LOW (indicating we want off at 70) and the pressure is 70 or greater the pump will turn on at 70.
  else if (digitalRead(cutOut) == LOW && mpxVal >= 70){
    digitalWrite(pumpPin, LOW);
    digitalWrite(led, LOW);
  } 

  // Timing of the Solenoid   
  digitalWrite(solenoid, HIGH);                         // sets the solenoid on
  digitalWrite(led, HIGH);                              // LEDturn the LED on 
  delay(buttonPushCounterOn * 1000);                    // buttonPushCounterOn * 1,000 = seconds. Solenoid opens and waits for __ seconds.
  digitalWrite(solenoid, LOW);                          // sets the solenoid off
  digitalWrite(led, LOW);                               // LED turn the LED off. 
  delay(buttonPushCounterOff * 1000);                  // buttonPushCounterOff * 60,000 = minutes. Solenoid closes and waits for __ min. 


  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):

  // print current pressure value: Bar
  lcd.setCursor(9,0);
  lcd.print(" ");
  lcd.print(mpxValBar, DEC);
  lcd.setCursor(12, 0);  
  lcd.print("Bar");

  // print current pressure value:  PSI
  lcd.setCursor(1,0); 
  lcd.print(" ");
  lcd.print(mpxVal, DEC);
  lcd.setCursor(4, 0); 
  lcd.print("PSI / ");
  delay (50);
}

I need the mpx data more regularly.

Then don't use delay(). Look at the BlinkWithoutDelay example in the IDE. It uses the principle of checking whether a timing period has elapsed each time through loop(). If so it takes the appropriate action. If not it can do other things such as reading inputs.

Alphafitz:
Each button push increases the loop time. I need the mpx data more regularly.

Well, if you’re going to use delay(), and do it in increments of 1000, you aren’t going to read that pin very often at all.

A few things…

Check the Examples directory of the IDE and have a look at Blink Without Delay. Use the technique in there to decide when to toggle the solenoid pin, and to decide when to allow the solenoid to be retriggered.

Don’t print stuff in an ISR. There are two reasons for this. The first is that you want to keep the ISR as short as possible so that anything else that uses an interrupt doesn’t get delayed, and the second is that many forms of output (I don’t know about the LCD library) use interrupt, and won’t work at all during an ISR, because interrupts are disabled during an ISR routine.

Any variable used in an ISR should be declared volatile, like: volatile int buttonPushCounterOn = 0;

Any variable used in an ISR should be declared volatile, like: volatile int buttonPushCounterOn = 0;

"Any variable used in an ISR and shared with non-interrupt state code should be declared volatile, like: volatile int buttonPushCounterOn = 0;"

const int  buttonPinOn = 1;                    // the pin that the ON pushbutton is attached to
const int  buttonPinOff = 0;                   // the pin that the OFF pushbutton is attached to

Those are NOT pin numbers. they are interrupt numbers.