dual "for" statement - neopixel colorWipe

So i’ve spent quite some time with this project, I have most of the functions working.

my arduino (redboard from sparkfun, set as uno in ide) will look for 2 switches on pins 11&12, both wired to ground and programmed with internal pullup.

there are 3 if statements
one looks for both switches to be “LOW” (This loop doesn’t work correctly)
the other 2 look for just one of the 2 switches to be “LOW” and will make the neopixels colorWipe to either the left or right in red or blue

My loop that doesn’t work is the void colorWipeDUAL
its function is to make both left and right scan out at the same time (like a traffic adviser for a vehicle)
the selection of color and time work but I realize that having two for statements isn’t working.
The red color will come on quickly then it will turn on the blue very slowly (and repeat as long as the switches are “LOW”

how can I restructure the loop to solve my issue.

here is my code, comments added for the identifications of key structures and information;

#include <Adafruit_NeoPixel.h>

#define left 12
#define right 11
#define PIN 13



int buttonState = 0;
int buttonState2 = 0;


Adafruit_NeoPixel strip = Adafruit_NeoPixel(56, PIN, NEO_GRB + NEO_KHZ800);


void setup() {

pinMode(left, INPUT);
  digitalWrite(left, HIGH);
pinMode(right, INPUT);
  digitalWrite(right, HIGH);

  strip.begin();
  colorWipe(strip.Color(5, 5, 5), 0); // dim white no chase
  strip.show(); // Initialize all pixels to 'off'

}


//loop goes forward, starts halfway
void colorWipe2(uint32_t c, uint8_t wait) {
  for(uint16_t i=29; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

//error with this loop 
void colorWipeDual(uint32_t c, uint8_t wait, uint32_t b) { 
 for (uint16_t i=29; i<strip.numPixels(); i++){ 
 for(int16_t t=28; t>-1; t--) {
     strip.setPixelColor(t, b); //t is the pixel number scans to the right (color currently set to red)
     strip.setPixelColor(i, c); //i is the pixel number scans to the left (color currently set to blue)
     strip.show();
     delay(wait);
   }
  }
 }

//loop goes in reverse working, starts halfway
void colorWipeREV(uint32_t c, uint8_t wait) {
  for(int16_t i=28; i>-1; i--) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}



void loop() {



  buttonState = digitalRead(left);
  buttonState2 = digitalRead(right);


 if ((buttonState == LOW) && (buttonState2 == LOW)) {                       //this works corrently
    // turn LED on:
    colorWipeDual (strip.Color(0, 0, 100), 10, strip.Color(100, 0, 0)); // middle out color wipe with RGB color (delay) then another RGB color
    strip.show();
    colorWipe(strip.Color(5, 5, 5), 0); // dim white no chase
    strip.show();
  }
    
if ((buttonState == LOW) && (buttonState2 == HIGH)) {
    // turn LED on:
    colorWipeREV(strip.Color(100, 0, 0), 20); // red
    strip.show();
    colorWipeREV(strip.Color(5, 5, 5), 0); // dim white no chase
    strip.show();
  }
 if ((buttonState2 == LOW) && (buttonState == HIGH)){
    // turn LED on:
    colorWipe2(strip.Color(0, 0, 100), 20); // blue
    strip.show();
    colorWipe(strip.Color(5, 5, 5), 0); // dim white no chase
    strip.show();
   
  }


}

see if this works

uint16_t j;
uint16_t HALFWAY = (strip.numPixels() / 2) - 1;
void colorWipeDual(uint32_t c, uint8_t wait, uint32_t b)
{
    for (uint16_t i = HALFWAY; i < strip.numPixels(); i++) 
    {

        strip.setPixelColor(HALFWAY - j, b);    //scans to the right (color currently set to red)
        strip.setPixelColor(i, c);              //scans to the left (color currently set to blue)
        j++;
        strip.show();
        delay(wait);
    }

}

Ah I see. it makes sense, thanks.

Unfortunately it works once, they will go at the same time once but then only the blue will go.
so by using serial monitor i realized that the “j” just kept counting, so i add an if statement, but then some pixels weren’t resetting to off, so I moved the main variables to inside the loop (see attached code)

working code, thanks for the help;

void colorWipeDual(uint32_t c, uint8_t wait, uint32_t b)
{
uint16_t j = 1;
uint16_t HALFWAY = (strip.numPixels() / 2) - 1;

    for (uint16_t i = HALFWAY; i < strip.numPixels(); i++) 
    {
     Serial.println (j);
        strip.setPixelColor(HALFWAY - j, b);    //scans to the right (color currently set to red)
        strip.setPixelColor(i, c);              //scans to the left (color currently set to blue)
        j++;
        strip.show();
        delay(wait);
          if (j==29){
          j = 1;
          }
    }

Try this. It works.

#include <Adafruit_NeoPixel.h>


#define RINGPIN 5


uint8_t NUMPIXELS = 16;      // total number of LED's in the ring display

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, RINGPIN, NEO_RGB + NEO_KHZ800);  // an instance for the LED ring display

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  Serial.begin(9600);
}



void loop() {

  //Ascend strip
  for (int i = NUMPIXELS / 2; i >= 0; i--) {
    //for (int i = 0; i < (NUMPIXELS / 2) + 1; i++) {
    strip.setPixelColor(i, strip.Color(0, 64, 0));
    strip.setPixelColor(NUMPIXELS - i, strip.Color(0, 64, 0));
    strip.show();
    delay(35);
  }

  // Descend Strip
  for (int i = NUMPIXELS / 2 ; i >= 0; i--) {
    //for (int i = 0; i < (NUMPIXELS / 2) + 1; i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0));
    strip.setPixelColor(NUMPIXELS - i, strip.Color(0, 0, 0));
    strip.show();
    delay(50);
  }

}