neopixels with push button

Hi

I'm building a light set for a scooter so i have 16 x red pixels that become running (KNIGHT RIDER STYLE) when the brake is pressedand the brightness increases

Also i have 2 sets 5 orange indicators left and right that also do a running sketch when the correct button is high
the code for the brake switch works well and the indicators but when i put the code together it seems to just ignore any of the code except for the red brake lights and the buttons don't work
code attached
thanks in advance
Marky

#include <Adafruit_NeoPixel.h>

#define BB_PIN 11
#define LB_PIN 9
#define RB_PIN 6

#define LB_PIN 5
//#define RB_PIN 6
#define BPIXEL_PIN 7      // Digital IO pin connected to the NeoPixels.
#define LPIXEL_PIN 3
#define RPIXEL_PIN 2 

#define BPIXEL_COUNT 16
#define LPIXEL_COUNT  5
#define RPIXEL_COUNT  5

Adafruit_NeoPixel BRAKELIGHT = Adafruit_NeoPixel(BPIXEL_COUNT, BPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel LEFT = Adafruit_NeoPixel(LPIXEL_COUNT, LPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel RIGHT = Adafruit_NeoPixel(RPIXEL_COUNT , RPIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BB_PIN , INPUT_PULLUP);
  BRAKELIGHT .begin();
  BRAKELIGHT .show(); // Initialize all pixels to 'off'
  LEFT.begin();
  LEFT.show(); // Initialize all pixels to 'off'
  RIGHT.begin();
  RIGHT.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Get current button state.
  bool newState_1 = digitalRead(BB_PIN );
  bool newState_2 = digitalRead(LB_PIN );
  bool newState_3 = digitalRead(RB_PIN );

  startShow_1(showType);
  // Check if state changed from high to low (button press).
  if (newState_1 == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState_1 = digitalRead(BB_PIN );
    if (newState_1 == LOW) {
      showType++;
      if (showType > 1)
        showType = 0;
    }
  }
  startShow_2(showType);
  // Check if state changed from high to low (button press).
  if (newState_2 == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState_2 = digitalRead(BB_PIN );
    if (newState_2 == LOW) {
      showType++;
      if (showType > 1)
        showType = 0;
      startShow_2(showType);
    }
  }
  startShow_3(showType);
  // Check if state changed from high to low (button press).
  if (newState_3 == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState_3 = digitalRead(BB_PIN );
    if (newState_3 == LOW) {
      showType++;
      if (showType > 1)
        showType = 0;
      startShow_3(showType);
  }
    }


}

void startShow_1(int i) {
  switch (i) {
    case 0: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    //  break;
    case 1: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);
    // break;
    case 2: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    // break;
    case 3: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);
    //break;
    case 4: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);

    case 5: setPixelColor(BRAKELIGHT .Color(50, 0, 0), 12);
      break;

  }
}
void startShow_2(int i) {
  switch (i) {
    case 0: setPixelColor(LEFT.Color(0, 0, 0), 12);
    //  break;
    case 1: setPixelColor(LEFT .Color(225, 0, 0), 12);
    // break;
    case 2: setPixelColor(LEFT .Color(0, 0, 0), 12);
    // break;
    case 3: setPixelColor(LEFT .Color(225, 0, 0), 12);
    //break;
    case 4: setPixelColor(LEFT .Color(0, 0, 0), 12);

    case 5: setPixelColor(LEFT .Color(50, 0, 0), 12);
      break;
  }
}
void startShow_3(int i) {
  switch (i) {
    case 0: setPixelColor(RIGHT.Color(0, 0, 0), 12);
    //  break;
    case 1: setPixelColor(RIGHT .Color(225, 0, 0), 12);
    // break;
    case 2: setPixelColor(RIGHT .Color(0, 0, 0), 12);
    // break;
    case 3: setPixelColor(RIGHT .Color(225, 0, 0), 12);
    //break;
    case 4: setPixelColor(RIGHT .Color(0, 0, 0), 12);

    case 5: setPixelColor(RIGHT .Color(50, 0, 0), 12);
      break;








  }
}

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < BRAKELIGHT .numPixels(); i++) {
    BRAKELIGHT .setPixelColor(i, c);
    BRAKELIGHT .show();
    delay(wait);

    
  
   {
     
    
   }
    
   
    LEFT .setPixelColor(i, c);
    LEFT .show();
   delay(wait);
  }
 
  {

  
      RIGHT.show(); // Initialize all pixels to 'off'
    RIGHT.begin();
    delay (50) ; // Delay 500ms before the light of another LED
  }
}

Don't you needt an "oldState" for each switch?

I tried that but still same results

While not your bug

  // Get current button state.
  bool newState_1 = digitalRead(BB_PIN );
  bool newState_2 = digitalRead(LB_PIN );
  bool newState_3 = digitalRead(RB_PIN );

declares booleans and they you check against LOW / HIGH. declaring them as byte would probably make more sense conceptually. (but this does not break your code).

looking at the main loop

  if (newState_1 == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState_1 = digitalRead(BB_PIN );
    if (newState_1 == LOW) {
      showType++;
      if (showType > 1)
        showType = 0;
    }
  }

you start with showType at 0, then you do a showType++; so showType is now 1 and you test against >1 and you return to 0. your startShow_x functions shows that you are willing to accept types up to 5, so are you sure you want to reset and just alternate between 0 and 1?

Aslo, agree with AWOL, you need to get your old states in the new states when done

Looking at your startShow_x functions

1/ so you are calling your own setPixelColor

void setPixelColor(uint32_t c, uint8_t wait) {

and you have a for loop which goes to the number of pixels in BRAKELIGHT, so 16 in your case but you also do in that same loop LEFT .setPixelColor(i, c); so you are trying to address pixels that do not exist as LPIXEL_COUNT is only 5.

2/ then you for loop ends and you call begin again on the RIGHT strip. why would you do that? You usually would do that in the setup() function to prepare the data pin for NeoPixel output - which you already did.

3/ Why did you comment out the break; in function startShow_1();?

what happens when you call it the first time showType is 0 and you execute this switch

  switch (i) {
    case 0: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    //  break;
    case 1: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);
    // break;
    case 2: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    // break;
    case 3: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);
    //break;
    case 4: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    case 5: setPixelColor(BRAKELIGHT .Color(50, 0, 0), 12);
    break;
  }

As you have removed the break, you actualy step through all the setPixelColor calls and end up with the one in case 5:. is that intended to cycle through the different patterns? (could be, but just want to be sure you have planned for this).

Thank You for taking the time J-M-L

i'm new to all this ive managed to get the three separate function working on a button ie left indicator right indicator and brake light below are the individual code the only change is the pixel count and pin number of the neo pixs

i've been trying for hours to get the code to compile and the last sketch i posted was the only way i could make it compile but it just seemed to run the code through all the light and ignore any button presses

this is my second project and I'm no expert on programming.

BRAKE LIGHT CODE

// This is a demonstration on how to use an input device to trigger changes on your neo pixels.
// You should wire a momentary push button to connect from ground to a digital IO pin.  When you
// press the button it will change to a new pixel animation.  Note that you need to press the
// button once to start the first animation!

#include <Adafruit_NeoPixel.h>

#define BUTTON_PIN   2    // Digital IO pin connected to the button.  This will be
                          // driven with a pull-up resistor so the switch should
                          // pull the pin to ground momentarily.  On a high -> low
                          // transition the button press logic will execute.

#define PIXEL_PIN    7    // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 16

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);

  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW) {
      showType++;
      if (showType > 1)
        showType=0;
      startShow(showType);
    }
  }

  // Set the last button state to the old state.
  //oldState = newState;
}

void startShow(int i) {
  switch(i){
    case 0: setPixelColor(strip.Color(0, 0, 0), 12);    // Black/off
          //  break;
    case 1: setPixelColor(strip.Color(225, 0, 0), 12);  // blue
           // break;
    case 2: setPixelColor(strip.Color(0, 0, 0), 12);  // red
           // break;
    case 3: setPixelColor(strip.Color(225, 0, 0), 12);  // red
            //break;
    case 4: setPixelColor(strip.Color(0, 0, 0), 12);  //blue
    
    case 5: setPixelColor(strip.Color(50, 0, 0), 12);  //blue
    break;
    
    
    
    
           
 
  }
}

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

LEFT INDICATOR

seems you are missing code

yeah i exceeded the 9000 character and posts in 5 minutes

the codes are basically all the same working individually i just need to add three buttons left indicator right indicator and brake switch the only other change is the pixel count and the colour

You have 3 strips represented in your code with 3 different objects: BRAKELIGHT, LEFT, RIGHT

#define BPIXEL_COUNT 16
#define LPIXEL_COUNT  5
#define RPIXEL_COUNT  5

Adafruit_NeoPixel BRAKELIGHT = Adafruit_NeoPixel(BPIXEL_COUNT, BPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel LEFT = Adafruit_NeoPixel(LPIXEL_COUNT, LPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel RIGHT = Adafruit_NeoPixel(RPIXEL_COUNT , RPIXEL_PIN, NEO_GRB + NEO_KHZ800);

if you look at the function setPixelColor

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

it takes a color c as input and a delay between each LED color change and basically turn on each LED in the strip one after the other with the color.

So if you were to call that in sequence for your 3 strips:

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {

// animate the BRAKELIGHT
  for(uint16_t i=0; i< BRAKELIGHT.numPixels(); i++) {
    BRAKELIGHT.setPixelColor(i, c);
    BRAKELIGHT.show();
    delay(wait);
  }

// animate the LEFT
  for(uint16_t i=0; i< LEFT.numPixels(); i++) {
    LEFT.setPixelColor(i, c);
    LEFT.show();
    delay(wait);
  }

// animate the RIGHT
  for(uint16_t i=0; i< RIGHT.numPixels(); i++) {
    RIGHT.setPixelColor(i, c);
    RIGHT.show();
    delay(wait);
  }
}

You would have the effects on each strips one after the other.

if you want to have them at the same time, then because you don't have the same number of LED in each strip, you need to decide how you want to handle that. one way to do this would be to notice that you have 16 LEDs for the BRAKELIGHT and 5 for LEFT and RIGHT, so roughly 3 times less. so you could decide to turn on the LEFT and RIGHT next pixel only after having turned on 3 pixels from the BRAKELIGHT

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {

  // animate the BRAKELIGHT
  for (uint16_t i = 0; i < 16 ; i++) { // 16 is  BRAKELIGHT.numPixels(), hardcoded here.

    BRAKELIGHT.setPixelColor(i, c);
    BRAKELIGHT.show();

    // LEFT and RIGHT have only 5 LEDs, so need to do some maths.
    if (i % 3 == 0) {
      // i modulo 3 will be 0 for i = 0, 3, 6, 9, 12, 15 so 6 values,we want only 5 values
      if (i != 15) {
        // we know here i is 0, 3, 6, 9, 12
        // i/3 will be 0, 1,2,3,4 which is exactly what we want for LEFT and RIGHT strips

        // animate the LEFT
        LEFT.setPixelColor(i / 3, c);
        LEFT.show();

        // animate the RIGHT
        RIGHT.setPixelColor(i / 3, c);
        RIGHT.show();
      } // end if i != 15
    } // end if i modulo 3
    delay(wait);
  } // end for
}

would that work for you??

Thanks again for your time i will try this out and get back to you
would the pixels initiate with a button press ?
also as this is for a scooter i would be braking while indicating so i guess that will also be a problem?

this is for a scooter i would be braking while indicating so i guess that will also be a problem?

For you and your insurer's sake, let's hope not.

I put the code in as below it compiles but nothing happens with button press and no lights

// This is a demonstration on how to use an input device to trigger changes on your neo pixels.
// You should wire a momentary push button to connect from ground to a digital IO pin.  When you
// press the button it will change to a new pixel animation.  Note that you need to press the
// button once to start the first animation!

#include <Adafruit_NeoPixel.h>

#define BB_PIN 12   
#define LB_PIN 4
#define RB_PIN 5                       
#define BPIXEL_PIN 6      // Digital IO pin connected to the NeoPixels.
#define LPIXEL_PIN 7  
#define RPIXEL_PIN 8

#define BPIXEL_COUNT 16
#define LPIXEL_COUNT  5
#define RPIXEL_COUNT  5



// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel BRAKELIGHT = Adafruit_NeoPixel(BPIXEL_COUNT, BPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel LEFT = Adafruit_NeoPixel(LPIXEL_COUNT, LPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel RIGHT = Adafruit_NeoPixel(RPIXEL_COUNT , RPIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BB_PIN , INPUT_PULLUP);
  BRAKELIGHT .begin();
  BRAKELIGHT .show(); // Initialize all pixels to 'off'
}

void loop() {
  // Get current button state.
  bool newState = digitalRead(BB_PIN );

  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BB_PIN );
    if (newState == LOW) {
      showType++;
      if (showType > 1)
        showType=0;
      startShow(showType);
    }
  }

  // Set the last button state to the old state.
  //oldState = newState;
}

void startShow(int i) {
  switch(i){
    case 0: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);    // Black/off
          //  break;
    case 1: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);  // blue
           // break;
    case 2: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);  // red
           // break;
    case 3: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);  // red
            //break;
    case 4: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);  //blue
    
    case 5: setPixelColor(BRAKELIGHT .Color(50, 0, 0), 12);  //blue
    break;
    
    
    
    
           
 
  }
}

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {

// animate the BRAKELIGHT
  for(uint16_t i=0; i< BRAKELIGHT.numPixels(); i++) {
    BRAKELIGHT.setPixelColor(i, c);
    BRAKELIGHT.show();
    delay(wait);
  }

// animate the LEFT
  for(uint16_t i=0; i< LEFT.numPixels(); i++) {
    LEFT.setPixelColor(i, c);
    LEFT.show();
    delay(wait);
  }

// animate the RIGHT
  for(uint16_t i=0; i< RIGHT.numPixels(); i++) {
    RIGHT.setPixelColor(i, c);
    RIGHT.show();
    delay(wait);
  }
}

I'm not about to replicate your hardware, and I'm not going to dry run your code, so why not add some debug prints, and get your code to tell you what it is doing?

I wish i knew how :confused:

Come on MarkyD... Do you really mean to modify something you will drive, mess around with electric signals and not do your homework? Do your part, read this and Getting Started with Arduino and explore all the links in the "Learn Arduino" section

You need a minimum of understanding if you want to do this.

something obviously missing in your code:

void setup() {
  pinMode(BB_PIN , INPUT_PULLUP);
  BRAKELIGHT .begin();
  BRAKELIGHT .show(); // Initialize all pixels to 'off'
}

don't you think you need also to initialize LEFT and RIGHT?

on the side note:

Is marky_dom the same person as MarkyD?

Anyway lets clear the air for a while:

So you are building a signal light unit for an electric scooter right?

so I assume you will be doing something like Left signal, Right signal and also break?

and for the brake I assume you would like to play a Larson Scanner such as the famous car "KIT" in knight rider? with increasing brightness?

Thats sounds reasonable...

now whats your input and whats your output?

I would assume since you are still in the process of development you are using push button as your input:
1 x Left PB
1 x Right PB
1 x Stop PB

for the led strip you are using Neo pixel? from your attach code I could say you are separating the Neo pixel into 3 groups

1 Neo strips for left
1 Neo strips for right
1 Neo strips for stop?

I see this project being a good one. becoming a good one.

so anyway I can see this project require a few creative thinking. One is that for the left and right, theres 3 function. One is turn all on, turn all off and the last one is blink.

well for the Brake?
Im still thinking , but I'm sure its does have all off.

Is marky_dom the same person as MarkyD?

Well, they have an identical IP address.

Care to explain, Marky?

I forgot which email account i used hope i've not broken any rules

it was easier to rejoin than wait for verifications etc

I'm just playing with the code still i've managed to get all the light to do the BRAKELIGHT cycle all in red i just need to separate them into 3 different sections so they work individually

Thanks J-M-L that extra bit got me this far

Ashraf_Zolkopli yes everything you mentioned is correct except i will be having larson scanner turn signals "indicator lights " and the brake light will also act as a normal light by way of dimming

void startShow(int i) {
switch(i){
case 0: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12); //off
break;
case 1: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12); //red bright scanner
break;
case 2: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12); //off

case 3: setPixelColor(BRAKELIGHT .Color(50, 0, 0), 12); //red normal running
break;

this is the code so far I've commented where the problems are happening so to understand the faults I'm doing?

// 

#include <Adafruit_NeoPixel.h>


#define BB_PIN 12
#define LB_PIN 5
#define RB_PIN 6
#define BPIXEL_PIN 11      // Digital IO pin connected to the NeoPixels.
#define LPIXEL_PIN 3
#define RPIXEL_PIN 4

#define BPIXEL_COUNT 16
#define LPIXEL_COUNT  5
#define RPIXEL_COUNT  5



// Parameter 1 = number of pixels in strip, 
// Parameter 2 = pin number 
// Parameter 3 = pixel type flags, 
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel BRAKELIGHT = Adafruit_NeoPixel(BPIXEL_COUNT, BPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel LEFT = Adafruit_NeoPixel(LPIXEL_COUNT, LPIXEL_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel RIGHT = Adafruit_NeoPixel(RPIXEL_COUNT , RPIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BB_PIN , INPUT_PULLUP);
  BRAKELIGHT .begin();
  BRAKELIGHT .show(); // Initialize all pixels to 'off'
  LEFT .begin();
  LEFT .show();
  RIGHT .begin();
  RIGHT .show();
}

void loop() {
  // Get current button state.
  bool newState = digitalRead(BB_PIN );
  bool newState1 = digitalRead(LB_PIN );
  bool newState2 = digitalRead(RB_PIN );

  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BB_PIN );
    if (newState == LOW) {
      showType++;
      if (showType > 1)
        showType = 0;
      startShow(showType);

    }
  }

  // Set the last button state to the old state.
  //oldState = newState;                              REMOVING THIS ALLOWS THE RUNNINGS PATERNS
}


void startShow(int i) {
  
  switch (i) {
    case 0: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    //  break;                                                                    REMOVING THIS GIVES ME THE DESIRED           BRAKE EFFECT AND LEAVES THE BREAKLIGHTS DIM ACTING AS A REAR LIGHT .


    case 1: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);
    // break;                                                                         REMOVING THIS GIVES ME THE DESIRED BRAKE EFFECT AND LEAVES THE BREAKLIGHTS DIM ACTING AS A REAR LIGHT .


    case 2: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);

    case 3: setPixelColor(BRAKELIGHT .Color(50, 0, 0), 12);
       break; //THIS WORKS 
                                                                               //THE CODE WORKS TO HERE EXCEPT ALL THE LIGHT "left right brakelight" FLASH  AT THE SAME TIME RED but it looks nice
  }
  
}
void startShow1(int i) {
  
  switch (i) {
    case 0: setPixelColor(LEFT .Color(0, 0, 0), 12);//this doesn't happen no orange lights appear at all just same loop as above
      break;

    case 1: setPixelColor(LEFT .Color(225, 100, 0), 12);//this doesn't happen no orange lights appears at all just same loop as above
    break;// 


    case 2: setPixelColor(LEFT .Color(125, 50, 0), 12);//this doesn't happen no orange lights appears at all just same loop as above

    case 3: setPixelColor(LEFT .Color(255, 100, 0), 12);//this doesn't happen no orange lights appears at all just same loop as above

    case 4: setPixelColor(LEFT .Color(0, 0, 0), 12);//this doesn't happen no orange lights appears at all just same loop as above
       break; //THIS WORKS 
    

}
  
}
void setPixelColor(uint32_t c, uint8_t wait) {

  // animate the BRAKELIGHT
  for (uint16_t i = 0; i < BRAKELIGHT.numPixels(); i++) {
    BRAKELIGHT.setPixelColor(i, c);
    BRAKELIGHT.show();
    delay(wait);
  }

  // animate the LEFT
  for (uint16_t i = 0; i < LEFT.numPixels(); i++) {
    LEFT.setPixelColor(i, c);
    LEFT.show();
    delay(wait);
  }

  // animate the RIGHT
  for (uint16_t i = 0; i < RIGHT.numPixels(); i++) {
    RIGHT.setPixelColor(i, c);
    RIGHT.show();
    delay(wait);
  }
}

You never call startShow1 so no wonder the code does not happen...

//oldState = newState; REMOVING THIS ALLOWS THE RUNNINGS PATERNS

well removing this ensures that while the button is pressed you keep calling the animation... as you tel the animation to wait 12 ms between each led movement it means the full pattern in setPixelColor takes less than 0,2 seconds.. you can't see much at the speed.. and it's even faster for LEFT and RIGHT

My 1st problem is all the leds run in red when i press the brake button

the orange indicator sequence does not happen

2nd the //oldState = newState; only allows it to run once so if im pressing the brake for more than 3

second it goes back to normal red dim lights

3rd void startShow1(int i) { is there in the coded

  oldState = newState;  //REMOVING THIS ALLOWS THE RUNNINGS PATERNS
}


void startShow(int i) {
  
  switch (i) {
    case 0: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
      break; //REMOVING THIS GIVES ME THE DESIRED BRAKE EFFECT AND LEAVES THE BREAKLIGHTS DIM ACTING AS A REAR LIGHT .


    case 1: setPixelColor(BRAKELIGHT .Color(225, 0, 0), 12);
     break; //REMOVING THIS GIVES ME THE DESIRED BRAKE EFFECT AND LEAVES THE BREAKLIGHTS DIM ACTING AS A REAR LIGHT .


    case 2: setPixelColor(BRAKELIGHT .Color(0, 0, 0), 12);
    break;

    case 3: setPixelColor(BRAKELIGHT .Color(50, 0, 0), 12);
       break; //THIS WORKS 
       //THE CODE WORKS TO HERE EXCEPT ALL THE LIGHT "left right brakelight" FLASH  AT THE SAME TIME RED but it looks nice
  }
  
}
void startShow1(int i) {
  
  
  switch (i) {
    case 0: setPixelColor(LEFT .Color(0, 0, 0), 12);//this dosent happen no orangr lights appers at all just same loop as above
      break;

    case 1: setPixelColor(LEFT .Color(225, 100, 0), 12);//this dosent happen no orangr lights appers at all just same loop as above
    break;// 


    case 2: setPixelColor(LEFT .Color(125, 50, 0), 12);//this dosent happen no orangr lights appers at all just same loop as above

    case 3: setPixelColor(LEFT .Color(255, 100, 0), 12);//this dosent happen no orangr lights appers at all just same loop as above

    case 4: setPixelColor(LEFT .Color(0, 0, 0), 12);//this dosent happen no orangr lights appers at all just same loop as above
       break; //THIS WORKS