Arduino (Counter as a Dead man Switch)

Hi PaulS,

I got some help last night and the DMS is working now.

void LcdCounter(){


    CounterMillis = millis();
    if (CounterMillis - CounterMillis1 >= interval2) {

    if (a < 40 && purge == 0 && stateRELAY1 == HIGH) // value of 40 for testing purpose.              
                                                                                 // The final goal will be 400 counts
   {                                                                          
    a ++;
    lcd_2.setCursor(11, 1);
    lcd_2.print(a);

    Serial.println(CounterMillis);  // for debug millis
    Serial.println(CounterMillis1); // for debug millis
    }
    
    else
    {
    if (purge == 1){
    a = 0;
    purge = 0;
    lcd_2.setCursor(11, 1);
    lcd_2.print(F("     "));
    }

    if (a >= 40) // value of 40 for testing purpose. 
                      // The final goal will be 400 counts
    
   {  
    stateRELAY1 = LOW;  //shutdown compressor
    stateRELAY2 = LOW;  //shutdown oxygen solenoid
    stateRELAY3 = LOW;  //shutdown relay 3
    lcd_2.setCursor(11, 1);
    lcd_2.print(F("Purge"));
    }
    }
    CounterMillis1 = CounterMillis;
    }
}

With this code, every time the purge occur, the air blow in a flowSensor and it reset the counter
to zero and it restart. If there is no blow during a count of 400, it shutdown 3 relays.

The only problem is that I found that millis is not equal to 1 second probably because my code
takes more than 1000ms to execute.

I add two lines for debug (serial print CounterMillis and CounterMills1) and if I substract
the two values I obtains 1383 instead of 1000.

If I deactivate all loops in my code and just keep the counter, it work and then millis do equal to 1000.

So for now I put an interval and the best I can do is 1000 millis = 9.25 seconds more or less since my finger is pressing the stopwatch on my phone to compare.

I will read a little on RTC to find a way to get a real counter in my code but a count of 400 is ok for now.

Monitoring the increase of PSI

PSI is the variable that stored the value of the air pressure.
I need to make sure that this value is increasing. If I can
get a good example on how to do it, I will then adjust the
TIME vs the PSI for 10 PSI each 20 seconds more or less.