A cyclic timer program with input dependent condition

I got your point. Let me test it. Thank you for helping.