You need a Finite State Machine.
In the example, state 0 would contain an interval value of 5, state 1 would be 10, etc.