Void Function/If statement question

What do i need to add to the last if statement, to make it that it will only proceed if LevelSense is >= 96 and if the void function WaitWaterSense is complete (WaitWaterSense is a timer)?

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  int LevelSense = 98;

  if (LevelSense >=96) WaterSenseWait(); // if levelsensor is 96% or more full complete void function WaterSenseWait

   if ( LevelSense <= 95)  
  {
        //do something
  }
  else if ( LevelSense >= 96) // here i want if levelsense>=96 and WaterSenseWait is complete
  {
    //do something here
  }
 

}

void WaterSenseWait(){
  //do timer here
}

Does WaitWaterSense() contain a loop that is waiting on something? If so then your program won't be able to do anything while waiting.

It looks like you are already doing that so I don't really understand...

if (LevelSense >=96) WaterSenseWait(); // if levelsensor is 96% or more full complete void function WaterSenseWait

ahh my bad. sorry there. In essence i simply have a water sensor but given when filling a water tank the water level can often get choppy i want to make sure that the water level is above 96%. So bassicly all i'm trying to achieve is if the water level sensor is above 96% for 5 seconds do task, if not, dont do task.

So your recommending i don't use the last if statement, but put it in the timer code instead? so in essence if levelSense reaches 96% start 5 second counter then do whatever.

if so my only problem with that is i want to see if the water level remains at 96% or more for 5 seconds and then do what is whatever is next.

If during the 5 seconds the water goes below 96%, you disable the TIMER.

When it again returns to >= 96% the TIMER is reset and enabled.

Actually you should use millis() function to time the 5 seconds. If the level remains above 96% then the timer will time out.

I can't test but this should work:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  static unsigned long prevMs = millis();
  unsigned long currentMs = millis();
  int LevelSense = 98;

  if (LevelSense < 96)
  {
    prevMs = currentMs;
  }
  
  if (currentMs - prevMs >= 5000)
  {
    // If you get here then level must have been >= 96 for 5 seconds!!!
  }
}

Just a minor point, but when you refer to a "void function", do you know what that means?