Resetting a float variable with push button

Good afternoon,

I hope I posted this in the correct section, was not sure if maybe it is better suited in the project section.

A quick background... I am very new to Arduino programming and have next to no experience working with programming language or electronics. I have a background with high voltage power distribution/utility equipment and plc's, and have formal education in this area with limited training in electronics. I have taken on a project creating an oil pumping system, controlled by arduino. For this I am using the Arduino Mega2560.

Getting to my programming issue: I have an LCD display (not serial), displaying the amount of oil pumped. I would like to be able to reset this value to zero by pressing a push button, and then restart the count of how much oil has been dispensed. I have my push button, momentary N.O. button, connected to ground, hooked to my input. The input is set high, so when the button is pressed the pin is pulled low. I have written some code so that I can press the button and have my oil pumped value return to zero. I did this by an if statement: if button is low value=0. However the problem I am running into is as soon as I release the button the pin goes high again and my value jumps back up to the reading before the button press.

This makes sense I can see exactly why it would happen, it is only low when pressed and then release the button it will go high again. I decided to try that if button is low, digitalWrite that input low. This holds the new value then as the input is now constantly being held low by the arduino. This however holds the value 0.00 all the time, and when I begin to flow oil through the system again, the variable stays as 0.

byte FOOTSWITCH = 31;
byte ESTOP = 4;
byte PUSHBUTTON1 = 5;
byte PUSHBUTTON2 = 6;

#define FLOWSENSORPIN 2 // flow sensor connected to pin 2
#define RELAY1 28      // PUMPING CONTROL RELAY (Drives the pump)
#define RELAY2 30      // PUMP RUNNING RED INDICATOR LAMP
#define RELAY3 32      // CYCLE COMPLETE GREEN INDICATOR LAMP 
#define RELAY4 34      // ALARM BLUE INDICATOR LAMP

//keypad variables below
long value = 0;                    //value in thousandths of an inch
int dec_switch = 0;                //0=integer entry, 1=decimal entry, 2=fractional entry
int dec_place = 0;                 //tracks decimal place 
int frac_switch = 0;               //switches to fraction mode 
int numerator = 0;                     //numerator value
int denominator = 0;                   //denominator value 
float frac_value = 0;                  //calculated decimal value of fraction
float liters = 0;                       //job liters with a floating decimal point
float litersb = 0;                     //total litres for the day floating decimal point
float pumpedmL = 0;                    //millilters input from keypad

 pinMode(ESTOP, INPUT);       //set estop as input to arduino
    digitalWrite(ESTOP, HIGH);  //NC contacts connect pin to GND. LOW for unactive, HIGH for ACTIVATED/PRESSED!
    
    pinMode(FOOTSWITCH, INPUT);      //Set foot switch as input to arduino
    digitalWrite(FOOTSWITCH, HIGH);  //NO contact connect pin to GND. LOW for pressed, HIGH for not pressed. 

     pinMode(PUSHBUTTON1, INPUT);      //Set black pushbutton as input to arduino
     digitalWrite(PUSHBUTTON1, HIGH);  //NO momentaty contact connected to GND. LOW for pressed, HIGH for not pressed.
    
     pinMode(PUSHBUTTON2, INPUT);      //Set black pushbutton as input to arduino
     digitalWrite(PUSHBUTTON2, HIGH);  //NO momentaty contact connected to GND. LOW for pressed, HIGH for not pressed.
     
     
    pinMode(RELAY1, OUTPUT);    //set pump relay CR as output
    digitalWrite(RELAY1, LOW); //Program starts with pump relay CR open/OFF. Activate with Foot Switch.

void loop()

if(digitalRead(PUSHBUTTON1)== HIGH)
  {
  liters = pulses;   //7.5 was not correct, 7.08125 more accurate.
  liters /= (7.08125 * 60);  //calculating liters
  pumpedmL = (liters * 1000);
  
  Serial.print(liters); Serial.println("Liters");
  lcd.setCursor(0, 1);
  lcd.print(liters); lcd.print("L Job      ");
  } 
  digitalRead(pumpedmL); digitalRead(value);
  lcd.setCursor(13, 1); lcd.print(value); 
  lcd.setCursor(18, 1); lcd.print("mL");

//if reset is pressed take liter count back to 0
  if(digitalRead(PUSHBUTTON1)== LOW)
  {
    digitalWrite(PUSHBUTTON1, LOW);
    liters = 0;
    lcd.setCursor(0, 1);
    lcd.print(liters);
  }

What I am trying to accomplish: example, power up, 0.00L dispensed. pump 6.50L, it displays 6.50L. one press of button wipes the 6.50 to 0.00 again. pump another 2.00L of oil. display 2.00L. I have researched the forums and googled, tried everything I can think of, but cannot figure out how to do this.

I am sure someone has done this before so hopefully there is a solution to my difficulties. Thank you in advance for any help you guys can give me,

Eric

ericw2015:
However the problem I am running into is as soon as I release the button the pin goes high again and my value jumps back up to the reading before the button press.

liters = 0;
pulses = 0;

Thank you!!! That did the trick, should have thought of that, I really appreciate it!