problem with Simple Timer program

I thought I would try the code in Reply #10 just for fun. I didn't have the SimpleTimer library and it became too much trouble to install it so I rewrote the code using millis() to do the timing. I don't really see any advantage adding 400 lines of library code.

And this code works just as well when connected to the PC or running from a battery pack (6xAA batteries).

unsigned long curMillis;
unsigned long intervalMillis = 4000;
unsigned long prevMillis;

void RepeatTask() {
  digitalWrite(13, ! digitalRead(13));  //this connects to LED

}

void setup() {
  Serial.begin(9600);
  pinMode(13,OUTPUT); // LED
  digitalWrite(13,LOW);
  
 }

void loop() {
    curMillis = millis();
    if (curMillis - prevMillis >= intervalMillis) {
       prevMillis += intervalMillis;
       RepeatTask();
    }
}

...R