How can I loop an led animation code?

Hello
I am developing a project with an RGB led and the esp8266. when I press a button on the blynk app witch is connected to virtual pin 0 the led changes color according to the code but the code runs only when I press the button, I want it to loop continuously how can I change the code

Thank you in advance

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define GREEN 2
#define BLUE 5
#define RED 4
#define delayTime 1000

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "xxxxx", "xxxxxx"); 


  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  pinMode(RED, OUTPUT);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);
  digitalWrite(RED, LOW);
}


BLYNK_WRITE(0) 
{
 int i=param.asInt();
 if (i==1) 
 {
    digitalWrite(RED, HIGH);
    delay(delayTime);
    digitalWrite(RED, LOW);
    delay(delayTime);
    digitalWrite(GREEN, HIGH);
    delay(delayTime);
    digitalWrite(GREEN, LOW);
    delay(delayTime);
    digitalWrite(BLUE, HIGH);
    delay(delayTime);
    digitalWrite(BLUE, LOW);
    delay(delayTime);
  }
}



void loop()

{
  Blynk.run();
}

Hello

instead of doing the animation on the button press. Make the button change the mode and in the loop depening on the current mode do the animation

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define GREEN 2
#define BLUE 5
#define RED 4
#define delayTime 1000

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";


int mode ; 

void setup()
{
  mode = 0 ; // Start in a known state 

  Serial.begin(9600);
  Blynk.begin(auth, "xxxxx", "xxxxxx"); 


  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  pinMode(RED, OUTPUT);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);
  digitalWrite(RED, LOW);
}


BLYNK_WRITE(0) 
{
 // Change state on button press 
 if( param.asInt() == 1 ) {
  mode = 1 ; 
 } else {
  mode = 0 ; 
 } 
}



void loop()
{
  Blynk.run();

  switch( mode ) {
    case 1:
      runModeOne();
      break; 

    defaul: {
      // Do nothing 
    }
  }
}

void runModeOne() {

  digitalWrite(RED, HIGH);
  delay(delayTime);
  digitalWrite(RED, LOW);
  delay(delayTime);
  digitalWrite(GREEN, HIGH);
  delay(delayTime);
  digitalWrite(GREEN, LOW);
  delay(delayTime);
  digitalWrite(BLUE, HIGH);
  delay(delayTime);
  digitalWrite(BLUE, LOW);
  delay(delayTime);
}

I have tried the code but it is giving me an error runModeOne was not declared in the scope

You can move the loop function to the end.