I need help for my code

Deva_Rishi:
Ah actually you could even get away with changing your RunningLights() like this :

void RunningLights(byte red, byte green, byte blue, int WaveDelay) {

int Position=0;
 
  for(int j=0; j<NUM_LEDS*2; j++)
  {
      Position++; // = 0; //Position + Rate;
      for(int i=0; i<NUM_LEDS; i++) {
        // sine wave, 3 offset waves make a rainbow!
        //float level = sin(i+Position) * 127 + 128;
        //setPixel(i,level,0,0);
        //float level = sin(i+Position) * 127 + 128;
        setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
                  ((sin(i+Position) * 127 + 128)/255)*green,
                  ((sin(i+Position) * 127 + 128)/255)*blue);
      }
     
      showStrip();
      if (Serial.available()) return;  // it's not pretty but it will sort of do what you want
      delay(WaveDelay);
  }
}


It will also exit the the function when incorrect data has been received, but it will exit.

Hi,

Thanks, it works very well.