I have this little project that will activate a single LED by using Two Pushbuttons. The scenario is that, after pressing PB1, I must wait for 5 seconds before pressing PB2 to make the LED lit.
I have ideas like using millis, however still dont know where to start.
So you need to split this problem into smaller pieces like, how do you make sure 5 seconds has pasted since pushing PB1 button. How do you know when pressing PB2, that timeout has passed...
This is still a bit unclear-- If you hold PB2 down for 5+ seconds would that count as waiting 5 sec, or would touching PB2 early make you have to start over? (like WAITING ->IDLE[label="if(PB2) && time<5sec)";
Come on guys, let's not scare king off. He needs to learn to crawl before he can run like a pro. Keep it simple. You're throwing third semester stuff at him.
I like knowing what it is supposed to do before jumping into code. From @kingzz21's description, is it clear what should happen if you hold down both buttons for 6 seconds and release them?
How do you know if the code is doing the right thing without a design?
Here's @paulpaulson's tightly packed code in wokwi:
Predict tapping the A0 button, and then immediately holding A1 for longer than 5 seconds. Then try it out and see if it works as expected, as specified, and as intended.
ETA: Try predicting holding A1 closed for 10 sec after startup.