While Schleife starten mit Virtuellen Button Blynk

Hey :slight_smile:
Hab ein kleines Problem in meinem Code weil ich nicht genau weiß wie ich eine while Schleife auf Knopfdruck starte... Ich habe einen Virtuellen Button in Blynk angelegt und möchte Solange der Button auf "An" ist das der Regenbogen Modus geloopt wird. Ist das so möglich? Hier der Code den ich soweit habe (der Funktioniert auch soweit) :

#define BLYNK_PRINT Serial
#include <Adafruit_NeoPixel.h> 
#include <SPI.h> 
#include <BlynkSimpleEsp8266.h> 
#include <ESP8266WiFi.h> 
#define PIN 2 // GPIO pin 
#define NUMPIXELS 18 // Number of pixels in strip 
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(18, PIN, NEO_GRB + NEO_KHZ800);


char auth[] = "authCode";

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "ssid", "password");
pixels.begin();
strip.show();
}

void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}


void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

BLYNK_WRITE(V1) // Widget WRITEs to Virtual Pin V2
{ 
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
  Serial.println(R);
  Serial.println(G);
  Serial.println(B);

for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(R,G,B)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
}
}

BLYNK_WRITE(V2)
{
  int i= param.asInt();
  if (i==1)
  {
    rainbowCycle(20);
    rainbowCycle(20);
    rainbowCycle(20);
    strip.clear();
    strip.show();
    
  }
}

BLYNK_WRITE(V3)
{
  int i= param.asInt();
  if(i==1) {
    theaterChaseRainbow(50);
    strip.clear();
    strip.show();
  }
}
void loop()
{
  Blynk.run();
  
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}