Got a bug somewhere, can't find it myself

The code I made (with help from this forum ... made so many stupid error, which I should have seen myself, but totally did not) is (almost?*) feature finished, but I made an upsi somewhere and can't for the life of me find it.

*= wanted one more animation ... but currently am convinced it would be too much, so I leave that for later.

Many values are subject to tweaking once I run it on real hardware. (only simulated so far, soldering it together is the next step)

// code was here comes in next post (in 5 minutes) due to post length restriction
(also sorry ... had to cut some comments in there ... and it seems that forum does not like tabs)

The idea is to have a bunch of leds (most in pairs of two) cycle through colors in their own speed.
On top of that there is a breathing animation of all active LEDs.
And sometimes a random LED turns on bright yellow for a very short time.

Problem is: Rouge LEDs are turning on and sometimes not off. (sometimes they do).

Maybe you can see what idiot me can't.


Update:
My blindness has been lifted:
I wrote:

  if (millis()>=nextTwinkle){
    twinkle();
	if (!twinkleStep){
		twinkleStep = true ;
		nextTwinkle=millis()+twinkleTime;
		twinkle();
[more if code]

while I should have:

  if (millis()>=nextTwinkle){
	if (!twinkleStep){
		twinkleStep = true ;
		nextTwinkle=millis()+twinkleTime;
		twinkle();
[more if code]

The first twinkle() led to rouge behavior since it set LEDs without a chance to reset.

#include <Adafruit_NeoPixel.h>
#include <math.h> 

#define PIN 11 // input pin Neopixel is attached to
#define NUMPIXELS 19 // number of neopixels in strip
#define delayval 20 // timing delay in milliseconds
#define ranMin 100 //minimum time for random intervall
#define ranMax 150 //maximum
#define anipause 100 //time between animation steps
#define anistep 6 //animation stepsize
#define ranTwinkleMin 1000 //minimum time for random intervall
#define ranTwinleMax 2500 //maximum
#define twinkleTime 20 //length of twinkle

#define colorStep 10 //change color this much each step

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int LEDColor[7][4]={{127,127,0,0},{127,127,0,0},{127,127,0,0},{127,127,0,0},{127,127,0,0},{127,127,0,0},{127,127,0,0}}; //LED block
int LED8Color[]={127,127,0,0}; //LED 2
int LED9Color[]={127,127,0,0}; //LED 4
int LED10Color[]={127,127,0,0}; //LED 6
int LED11Color[]={127,127,0,0}; //LED 8
int LED12Color[]={127,127,0,0}; //LED 10
int LED13Color[]={127,127,0,0}; //LED 12

unsigned long nextMillis[]={0,0,0,0,0,0,0};
int ranpau[]={0,0,0,0,0,0,0};

int animation=0; // for breath animation, value in degrees for cos function
unsigned long nextAni=0;
unsigned long nextTwinkle=0;
bool twinkleStep=false;
int twinkleLED=0; // defines which LED should twinkle

void setup() {
  // Initialize the NeoPixel library.
  pixels.begin();

  Serial.begin(9600); // debug only

  for (int i=0; i <= 7 ; i++) // set random intervalls for all in LED block
  {
    ranpau[i]=ranPause();
  }
  nextAni=millis()+anipause; // set when breath ani updates
  nextTwinkle=millis()+random(ranTwinkleMin, ranTwinleMax); // time for next twinkle

}

void loop() {
  for (int i=0; i < 7 ; i++) // loop LED block
  {
    if (millis()>=nextMillis[i]){ //has LED i an event upcoming?
      nextMillis[i]=millis()+ranpau[i]; //update time for next change ?? maybe put this at end?
      switch (i) {
        case 0: 
          pixels.setPixelColor(0, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          pixels.setPixelColor(12, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          break;
        case 1:
          pixels.setPixelColor(2, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          pixels.setPixelColor(13, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          break;
        case 2:
          pixels.setPixelColor(4, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          pixels.setPixelColor(14, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          break;
        case 3:
          pixels.setPixelColor(6, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          pixels.setPixelColor(15, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          break;
        case 4:
          pixels.setPixelColor(8, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          pixels.setPixelColor(16, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          break;
        case 5:
          pixels.setPixelColor(10, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          pixels.setPixelColor(17, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
          break;
        case 6:
         pixels.setPixelColor(18, pixels.Color(breath(LEDColor[i][0]),breath(LEDColor[i][1]),breath(LEDColor[i][2])));
         break;
        default:
         break;
      }
      colorRotation(i,LEDColor[i][0],LEDColor[i][1],LEDColor[i][2],LEDColor[i][3]); // update to next color in next call
      pixels.show();
    }
  }
  
  if (millis()>=nextAni){ // update breath animation
    animation=animation+anistep;
    nextAni=millis()+anipause;
  }
  
  if (millis()>=nextTwinkle){
    twinkle();
    if (!twinkleStep){
      twinkleStep = true ;
      nextTwinkle=millis()+twinkleTime;
      twinkle();
    } else {
      nextTwinkle=millis()+random(ranTwinkleMin, ranTwinleMax);
      twinkleStep=false;
      switch (twinkleLED){
        case 0:
        case 12:
          pixels.setPixelColor(0, pixels.Color(breath(LEDColor[0][0]),breath(LEDColor[0][1]),breath(LEDColor[0][2])));
          pixels.setPixelColor(12, pixels.Color(breath(LEDColor[0][0]),breath(LEDColor[0][1]),breath(LEDColor[0][2])));
          break;
        case 2:
        case 13:
          pixels.setPixelColor(2, pixels.Color(breath(LEDColor[1][0]),breath(LEDColor[1][1]),breath(LEDColor[1][2])));
          pixels.setPixelColor(13, pixels.Color(breath(LEDColor[1][0]),breath(LEDColor[1][1]),breath(LEDColor[1][2])));
          break;
        case 4:
        case 14:
          pixels.setPixelColor(4, pixels.Color(breath(LEDColor[2][0]),breath(LEDColor[2][1]),breath(LEDColor[2][2])));
          pixels.setPixelColor(14, pixels.Color(breath(LEDColor[2][0]),breath(LEDColor[2][1]),breath(LEDColor[2][2])));
          break;
        case 6:
        case 15:
          pixels.setPixelColor(6, pixels.Color(breath(LEDColor[3][0]),breath(LEDColor[3][1]),breath(LEDColor[3][2])));
          pixels.setPixelColor(15, pixels.Color(breath(LEDColor[3][0]),breath(LEDColor[3][1]),breath(LEDColor[3][2])));
          break;
        case 8:
        case 16:
          pixels.setPixelColor(8, pixels.Color(breath(LEDColor[4][0]),breath(LEDColor[4][1]),breath(LEDColor[4][2])));
          pixels.setPixelColor(16, pixels.Color(breath(LEDColor[4][0]),breath(LEDColor[4][1]),breath(LEDColor[4][2])));
          break;
        case 10:
        case 17:
          pixels.setPixelColor(10, pixels.Color(breath(LEDColor[5][0]),breath(LEDColor[5][1]),breath(LEDColor[5][2])));
          pixels.setPixelColor(17, pixels.Color(breath(LEDColor[5][0]),breath(LEDColor[5][1]),breath(LEDColor[5][2])));
          break;
        case 18:
          pixels.setPixelColor(18, pixels.Color(breath(LEDColor[6][0]),breath(LEDColor[6][1]),breath(LEDColor[6][2])));
          break;

        case 1: // only temp below here ... maybe permanent if I can't come up with an animation idea.
          pixels.setPixelColor(1, pixels.Color(0,0,0));
          break;
        case 3:
          pixels.setPixelColor(3, pixels.Color(0,0,0));
          break;
        case 5:
          pixels.setPixelColor(5, pixels.Color(0,0,0));
          break;
        case 7:
          pixels.setPixelColor(7, pixels.Color(0,0,0));
          break;
        case 9:
          pixels.setPixelColor(9, pixels.Color(0,0,0));
          break;
        case 11:
          pixels.setPixelColor(11, pixels.Color(0,0,0));
          break;
        default:
          pixels.clear();
          break;
      }
    pixels.show();
    }
  }
  delay(delayval); // simulator only
}

int ranPause(){ // ran nums for pause
  return random(ranMin, ranMax);
}

int breath(int colorin){ // changes brighness depending on animation step
  int colorout= colorin * ((cos(((animation%360)/180*M_PI))+1.5)/2.5);
  return colorout;
}

void twinkle(){
  twinkleLED = random(0,NUMPIXELS); // get a random pixel
  pixels.setPixelColor(twinkleLED, pixels.Color(255,255,0)); // make it bright yellow
  pixels.show(); // show it
}

void colorRotation(int LED,int RredColor,int RgreenColor,int RblueColor,int circ){ // cycles through all vcolors
  switch (circ) { // circ defines at which point the color cycle is.
    case 0: //green
        if (RgreenColor <= 254) {
              RredColor=RredColor-colorStep;
          RgreenColor=RgreenColor+colorStep;
          if (RredColor<0) {RredColor=0;}
          if (RgreenColor>255) {RgreenColor=255;}
        }
     else {
          circ++;
        }
        break;
    case 1: //blue
     if (RblueColor <= 254) {
       RgreenColor=RgreenColor-colorStep;
       RblueColor=RblueColor+colorStep;
          if (RgreenColor<0) {RgreenColor=0;}
          if (RblueColor>255) {RblueColor=255;}
     }
     else {
          circ++;
        }
     break;
    case 2: //red
     if (RredColor <= 254) {
       RblueColor=RblueColor-colorStep;
       RredColor=RredColor+colorStep;
          if (RblueColor<0) {RblueColor=0;}
          if (RredColor>255) {RredColor=255;}
     }
     else {
          circ=0;
        }
     break;
    default:
     circ=0;
     break;
  }
  // update colors:
  LEDColor[LED][0]= RredColor;
  LEDColor[LED][1]= RgreenColor;
  LEDColor[LED][2]= RblueColor;
  LEDColor[LED][3]= circ;
}

for (int i=0; i <= 7 ; i++) "ranpau" has seven elements.
Oops.

TheMemberFormerlyKnownAsAWOL:

for (int i=0; i <= 7 ; i++)

"ranpau" has seven elements.
Oops.

Facepalm And after I did that mistake already and corrected it.
Thanks. But ... unfortunately there is are more ... (that could not and didn't cause the rouge LEDs

The marked red ones should not be on. And sometimes an LED flashes yellow /changes to yellow that should not. Intention was that one every one to two seconds would flash.