I am trying to learn to work with timers and I get that the IntervalMilliseconds value acts as a trigger event, but I want to put a timer in an app; either counting up or counting down, but I cannot seem to figure it out. I have found that Thunkable classic has a clock feature which works well in these situations, but am wondering if there is a way to do it with the timer feature that is currently available?
Static:
You can use a timer for counting. What I do is put a 1 second (1000ms) timer on loop and if I want to count a specific time what I do is a for loop is update a variable every time is fired.
If you want it to count up you add, if you want it to count down you substract it.
To have it set to a number what I do is add a if statement when it gets to number I want it to.
(I included a picture… the do something block is where you would update a label or also)
Dynamic:
Same thing but you need a variable for the if statement so you can change it with a text input or buttons
Also keep in mind that to have a counter like you want you should have a button to enable it so it doesn’t fire off whenever you open the screen
Good luck! Hope I could help!
You can also take a look at the “Tempus” sample app. The tutorials need to be updated, but there are quite a few examples of working with the Timer component.
If you only need the occasional trigger, you can put a “wait n seconds” block in the logic stream (where n can be any value, including a variable that is set somewhere else).
What happens is that the logic block will start and when encountering the “wait” instruction, will be pending there until that time elapse. Then the function will resume from that point.