cirocastro Posted May 3, 2018 Report Share Posted May 3, 2018 Hi everyone! Need a little enlightenment in here... my project works fine if i write it in the "main routine," but then when i try to organize it and break into subroutines it stops working, so i am doing one step at a time to see where i'm messing thing up. What i found out is the following: if i am in the "main routine" and have T0 as a 5s timer, connected to an input, it behaves as expected: input on -> timer decreases from 5s -> timer reaches 0 -> T0 value=1 after it finishes counting: T0 value=1-> input off, then on again-> T0=0, current timer value resets to 5s-> timer decreases from 5s etc etc if i open the input before countdown finishes: input on-> timer decreases ->input off, then on again->current value resets to 5s and restarts countdown But then, when i have my input calling a subroutine, and the subroutine having the same input connected to the same 5s timer, what happens is: input on -> timer decreases from 5s -> timer reaches 0 -> T0 value=1 after it finishes counting: T0 value=1-> input off, then on again-> T0=1, current timer value DOES NOT resets to 5s-> timer gets stuck with T0=1 if i open the input before countdown finishes: input on-> timer decreases ->input off, then on again->current value DOES NOT resets to 5s and countdown resumes from where it stopped before input was turned off the return to main routine function is activated by the T0=1 condition, and the *&%#$#%@ part is that when it finishes counting and returns to main, and then my input calls the subroutine again, my timer is already set at 1, and the program bugs. Is this expected? Am i doing something wrong? Do i have to work differently when using subroutines? Hope someone can understand my issue description and can help me =P Thanks! Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.