60 Second Countdown Timer?

I’ve found lots of examples of countdown timers, but none that really fit the case I’m working on: a simple 60 second countdown timer. Has anyone found a way to generate a simple timer that counts down from 60 to 0 and then will automatically advance to another state or screen?

The only way I can think to do this is to manually create 60 different states in a dynamic panel and the actions that automatically tic through the numbers.


Here’s a solution. All of the script is in the hotspot. Be sure to copy all three widgets to your file. You can hide the widget containing the current time (in milliseconds)

countdowntimer.rp (55.3 KB)

Here is a simple timer function I created years ago and have used in numerous prototypes since.

Generic Timer.rp (136.0 KB)

The basic method is to use a dynamic panel with at least two states. Use the action “set panel to state: Next” and select the checkboxes, “Wrap from last to first” and “Repeat every 1000 ms”. This sets up an automatic looping function so the dynamic panel changes states back and forth every 1000 ms = 1 sec. Anything or nothing at all can be in each state, but I find it best to have a rectangle widget in State 1, used to set and track the number of seconds before the timer expires. On each state change, the number (text on that widget) is decremented by 1. When it is less than or equal to zero, it expires and whatever code you need is executed.

I applied it to your need to change pages. The Home page will automatically open Page 1 after 6 seconds (to demonstrate the capability quicker) and then Page 1 will go back to Home automatically after 60 seconds. There are examples of how to pause, restart, reset, cancel it. To change the timer duration, simply set the text on timer1 to any number (of seconds). To change the timer resolution (check its time value more or less frequently) just set it to change states every N milliseconds (e.g., 500 for every half-second or 10000 for every 10 seconds) and change your decrement value accordingly.

Once set up, all you need to do to change the duration is change the value of the timer1 widget in State 1 of the Timer Control dynamic panel. You can reset it again and again if needed, and set up multiple timers to run at the same time.

You can use this method to time all sorts of things, set up stopwatches as well as countdown timers, turn it into a master, etc.