I have to create a IF statement that does the following:
IF both btnNow and btnPreve are equale AND the timer has elapsed five seconds execute PING otherwise execute PONG.
But my code wont wait the five seconds.
Any suggestions?
The time will be reached, but with tmrPrev = millis(); after a 600ms delay, the code will execute every 5.6 seconds rather than every 5 seconds. Better would be to use tmrPrev += 5000 to avoid this "drift" (I'd also move delay(600); out of each branch of the if to the bottom of loop).
You have declared your variables btnNow and btnPrev to be the same so your if statement will always be true after every 600 millisecond delay and will never execute the else if statement. Not sure what you're looking for, but I made a few changes to your code to change btnNow and btnPrev to not being equal after 5 seconds.
UPD. @christopbtnNow and btnPrev are 5, so equal always, millis() - tmrPrev <= 5000UL is true, so will tmrPrev = millis(); executed and again and again.
I think the answer to OP is: