Hi all! I'm lost.

Hi all!
I’m lost.
I’m trying to make a simple single button that if you press it once, it goes into state 1. Double press it within 2 seconds, it goes in to state 2. Longer than 2 seconds it goes back to state 0.
I can’t seem to get it from state 1 to state 0 after the 2 second delay.
Your help would be greatly appreciated!

Also, will the millis() count ever get so high that it overflows the Arduino and resets it?
Thanks guys
Chris

https://gist.github.com/cbonzo69/c1711c0299e6f0988f9eb391c430c7bb
https://gist.github.com/cbonzo69/a43d8de3b3066f9f2467a4b7a2d9b68f

The millis number will overflow (rollover back to zero), after approximately 50 days.

@marmil
Thank you Sir!

This sort of thing is much easier if if you use Bounce and elapsedMillis. Let those libs do the math and timing (any automatically handle internal numerical overflow properly), so you can just respond to the events and know how much time elapsed.

@PaulStoffregen
Thank you. What is the second variable in the Bounce statement?

@marmil ​ goodness 50 days??? That is a shocking long time for me lol

@Cristian_Martinez I think the longest I’ve continuously run something was an UNO that ran for about 23 days straight, so I didn’t even get close to maxing out my use of millis!

Ive never rub anything over 24 hours. Most of my stuff is wearable lol