i think the code will need to keep track of a "state".
in the first state, it monitors pb1. when pressed it captures a timestamp (i.e. timestamp = millis();), turns on the LED and changes to state 2
in the 2nd state, it monitors pb2 and checks if the time has expired: if (millis() - timestamp) > 20,000). if pb2 is pressed, turn off the LED and change to change 1st state. if the time expires, change to a 3rd state that uses a timer to toggle the LED on/off and monitors pb2. when pb2 is pressed, make sure the LED is off and change to the 1st state
Hello matrica1996
What is the desired function of your sketch?
Take some time and describe the desired function of the sketch in simple words and this very simple.
Have a nice day and enjoy coding in C++.