Created
June 7, 2022 17:19
-
-
Save piotr-piatkowski/d1c7ae151e5c9e314f30217e52882796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long next_state_change = 0; | |
long state = -1; | |
void loop() { | |
if(digitalRead(PIN_BUTTON) == LOW) { | |
state = 5; | |
// it will start counting after releasing button | |
next_state_change = millis() + 10000; | |
} | |
else if (millis() >= next_state_change) { | |
if (state == 5) { | |
state = 0; | |
} | |
else { | |
state = (state + 1) % 4; | |
} | |
next_state_change = millis() + 1500; | |
} | |
switch(state) { | |
case 0: | |
// .... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment