I have written a library that should help with this.
Try something like this:
#include <"Timing.h">
class StateMachine
{
int state = 1;
public:
void next()
{
switch(state){
case 1: digitalWrite(13,HIGH); events.add(1000,next); break;
case 2: digitalWrite(13,LOW); events.add(1000,next); break;
default: state = 1;}
state++;
}
};
// You also need some code that uses this class
For example the for loop would be replaced with:
if(state < 4){something; state++;}
EDIT: You posted while I was writing. Use this code if you add another thing with delays.