how to get a delay in an if statment


i would like to put a time statment/delay in an if statment, have searched but cant find any info this is what id like to do.

if ((inputa ==low) && (inputb ==low)) they both have to be low > 20 seconds.

then do this…

maby someone could point me in the right direction thank you

You can't, but you could note the time of the first going low event, and note the time of the second going low event, and subtract the two. Use "millis()" to record the time.

This isn't going to be possible with just an if statement. This requires code to keep track of both the IO states and some timing.

First, look at the blink without delay example for how to handle timing without using delay().

Your code is going to be broken down into several parts. First is the code that monitors a given input, and keeps track of how long it has been low, then sets a bool flag when it's been low for a specific amount of time. Use the blink without delay code as the basis for this code. Think about what you want your previousMillis value to be; ie, when do you update this value. That will be the main change you need to make in the code.

You'll want that code running for two separate IO points, which is going to require to separate sets of state variables. Ideally, you'll want to avoid duplicating code as much as possible.

After all that is working, it's just a simple matter of writing an if statement that checks flaga and flagb to determine if both input have been low for greater than 20 seconds.

thanks for the help, i will read up in boolean and mills