I’m adding a switch statement in my sketch. I have a bit of a dilemma though. Here’s what I want to do. Not code just trying to give you an idea of what I’m trying to accomplish.
case 1:(this is running)
if (val = anotherval)
start seconds timer and do something else UNTIL seconds timer = 30
set variable to select case 2 when timer runs out
My code works ok but I the problem is there is a chance that after the if statement is true val will be < anotherval(if statement is false) then the countdown will start over once its true again… I need to find a way to make the counter stay active even if while the counter is running its not true anymore. Then after countdown is finished set it to goto case 2. hope that makes sense.
I’m also wondering how you guys recommend setting up a timer like that?
unsigned long counter;
if (millis() > counter)
counter = counter + 1000
if counter / 1000 = 30//check to see if counter has reached 30 seconds
set variable to goto case 2