Programming bug

Hey, I'm making a code to turn on an LED for 5 seconds, off for 1 second, then on for 4 seconds, off for 1, on for 3, off for 1, on for 2, off for 1, on for 1, off for 1, in a loop.
My code is not working:

#define SECONDS 1000
unsigned long previousMillis = 0;
void setup() {
 // put your setup code here, to run once:
 pinMode(13,OUTPUT);

}

void loop() {
 // put your main code here, to run repeatedly:
 int counter = 5;
 unsigned long currentMillis = millis();
 digitalWrite(13,HIGH);
 while(counter > 0) {
   
   if (currentMillis - previousMillis >= counter*SECONDS) {
     previousMillis = currentMillis;
     digitalWrite(13,LOW);
     
     if (currentMillis - previousMillis >= SECONDS) {
       previousMillis = currentMillis;
       digitalWrite(13,HIGH); 
     }
   }
   counter--;
 }
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

You could tell us what it is or is not doing.

Weedpharma

To flip the state of a pin whatever it is initially you can use

digitalWrite(pin, !digitalRead(pin));

UKHeliBob:
To flip the state of a pin whatever it is initially you can use

digitalWrite(pin, !digitalRead(pin));

On an AVR, but not on every Arduino board. See Redirecting to Google Groups