There were problems with the following lines. Press "Play" when you're ready to try again.

DONE!
(Click anywhere)

Ratfactor's Sequence Timer

To use this timer:

  1. Enter a sequence into the text area above (examples below).
  2. Click the big 'Play' button at the top of the page.

Sequences by Example

A single 30 second timer:

30s

Four repetitions of a 30 second timer ("four reps of thirty seconds"):

4x 30s

A single sequence of one 3 second timer followed by a 5 second timer:

3s 5s

Ten repetitions of a sequence of 3 seconds followed by 5 seconds:

10x 3s 5s

A 100 rep sequence of three timers labeled "Row your boat". Labels are shown when the timer is playing to describe what the timer sequence represents.

100x 3s 5s 1s ; Row your boat

For a bigger example, here's my actual PT workout: timerseq-pt.txt

Auto-save

When you press "Play", your script is stored in your browser's localStorage. When you re-visit this page, that script should load immediately.

Specification

Sequence reps "x"

A sequence may begin with an optional repetition count followed by the letter 'x' (e.g. 3x). A missing repetition count is the same as an implicit "1x" (the sequence will only play once).

Sequence times

One or more times are specified with either an 's' or 'm' unit for seconds or minutes. Whole integers only (no decimal or fractional amounts).

Times are separated by one or more spaces (e.g. 5s 4s 3s 2s 1m).

Note: You cannot specify times in a combination of minutes and seconds. 1 minute and 30 seconds will need to be expressed as 90 seconds.

Description ";"

Anything after a ';' character is the description for the sequence. Descriptions are optional, but can be extremely useful if there are a large number of sequences.

Comments "#"

A line that begins with the '#' character is a comment and is ignored. Blank lines are also ignored.

Why?

I have a series of physical therapy exercises I should be doing multiple times per day. The thing I've discovered about doing these is that I actually enjoy the exercise itself, but doing it still felt like a chore. It turns out, it was because of all the counting.

One of my exercises has me holding a position for 5 seconds for 2 sets of 15 repetitions ("reps"). Another has me repeat a motion 30 times. Between the durations and repetitions, I'm counting 310 times.

And ideally, I'd be doing this three times per day.

My mind tends to wander while I'm counting. And, quite frankly, I want it to wander. I'd really like to just zone out and listen to some music and enjoy the exercise.

As a computer programmer, the solution is to make a program to help me count. But I couldn't figure out how to let the program know I'd performed each action. Pressing a touch-screen button for every "rep" would be just as tedious as counting like a normal human being.

Eventually, I realized I could just pre-program a whole workout as a sequence of times and as long as I kept up with it, I wouldn't need to hit any buttons at all. It would be like following along with one of those old TV exercise programs. (But with the advantage of a pause button.)

I also knew it was going to take a lot of trial-and-error to get the sequence timings right. Editing the program to get it right (or worse, having to edit way later after I've forgotten how it works) sounded terrible. Thus was born the idea for the "mini language" you see above.

The temptation, by the way, to add a couple control flow constructs (if/else, loops) so I could say this was a "programmable" timer was very high. But simply having the sequences in a text form (as opposed to an equivalent interface with buttons and number fields) makes this thing dirt-simple to script. If I really need to generate a page-worth of complicated sequences, I'll just do it in an external tool and paste them in. See also my writeup about DSLs.

ratfactor.com