Running Loop once and leaving LED lit until button released

Hello I am trying to use WS2812B LED's to make brake lights for my motorcycle.

I have written a program that lights up an 8x8 panel from the center to the outside when I press button3.

Button 1 and 2 are left and right blinkers so it is okay if they loop.

The problem is the program loops and keeps lighting from the inside out over and over. I want this to happen once and then stay lit until i release the button. What am I doing wrong?

Bonus:

*how do I control the brightness of the LED's using fastLED??
*how do I group LED's - like ROW1 = LED 0-7, ROW2= 8-15... and so on... ?

brake.ino (16.1 KB)

Use a state machine.

Add a variable oldButtonState = 0;.

if(buttonState1 == HIGH && oldButtonState == LOW) {
// "braking" code here
oldButtonState = HIGH; // so this block can only run once
}

if(buttonState1 == LOW && oldButtonState == HIGH) {
// "stop braking" code here
oldButtonState == LOW;
}

Leo..

Okay thanks Leo - I got it to work

but now - I set my stop braking code to be the LED at a lower brightness - which will be my running tail light - so now at the beginning of each code I set all the LED to black so the blinker or stop light can be seen easier.

This screwed up my brake light - it is looping again - if i remove the set LED to black coding from the beginning it works good again - why would the black coding do this?

why would the black coding do this?

Line 32 is wrong, mind you this crystal ball is sometimes not very reliable so you better post your code so we can check.

#include <bitswap.h>
#include <chipsets.h>
#include <color.h>
#include <colorpalettes.h>
#include <colorutils.h>
#include <controller.h>
#include <cpp_compat.h>
#include <dmx.h>
#include <FastLED.h>
#include <fastled_config.h>
#include <fastled_delay.h>
#include <fastled_progmem.h>
#include <fastpin.h>
#include <fastspi.h>
#include <fastspi_bitbang.h>
#include <fastspi_dma.h>
#include <fastspi_nop.h>
#include <fastspi_ref.h>
#include <fastspi_types.h>
#include <hsv2rgb.h>
#include <led_sysdefs.h>
#include <lib8tion.h>
#include <noise.h>
#include <pixelset.h>
#include <pixeltypes.h>
#include <platforms.h>
#include <power_mgt.h>

#include "FastLED.h"

// fast led constants
#define DATA_PIN    3        // change to your data pin
#define COLOR_ORDER GRB      // if colors are mismatched; change this
#define NUM_LEDS    256          // change to the number of LEDs in your strip
#define FRAMES_PER_SECOND  120



// change WS2812B to match your type of LED, if different
// list of supported types is here:
// https://github.com/FastLED/FastLED/wiki/Overview

#define LED_TYPE    WS2812B
#define BRIGHTNESS          200
#define DIM         10
#define ALL 0-255


const int buttonPin1 = 5;     // the number of the pushbutton pin
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 10;

// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int oldButtonState3 = 0;


// this creates an LED array to hold the values for each led in your strip
CRGB leds[NUM_LEDS];




void setup()
{
    delay(3000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  // the wiki features a much more basic setup line:
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

Serial.begin(9600);

// initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
  
  // List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();


uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
}

 void loop() 
{  // read the state of the pushbutton value:
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
  

  if(buttonState3 == HIGH && oldButtonState3 == LOW){

 


  // left tail light black
  
      leds[0] = CRGB::Black;
      leds[1] = CRGB::Black;
      leds[2] = CRGB::Black;
      leds[3] = CRGB::Black;
      leds[4] = CRGB::Black;
      leds[5] = CRGB::Black;
      leds[6] = CRGB::Black;
      leds[7] = CRGB::Black;
      leds[8] = CRGB::Black;
      leds[9] = CRGB::Black;
      leds[10] = CRGB::Black;
      leds[11] = CRGB::Black;
      leds[12] = CRGB::Black;
      leds[13] = CRGB::Black;
      leds[14] = CRGB::Black;
      leds[15] = CRGB::Black;
      leds[16] = CRGB::Black;
      leds[17] = CRGB::Black;
      leds[18] = CRGB::Black;
      leds[19] = CRGB::Black;
      leds[20] = CRGB::Black;
      leds[21] = CRGB::Black;
      leds[22] = CRGB::Black;
      leds[23] = CRGB::Black;
      leds[24] = CRGB::Black;
      leds[25] = CRGB::Black;
      leds[26] = CRGB::Black;
      leds[27] = CRGB::Black;
      leds[28] = CRGB::Black;
      leds[29] = CRGB::Black;
      leds[30] = CRGB::Black;
      leds[31] = CRGB::Black;
      leds[32] = CRGB::Black;
      leds[33] = CRGB::Black;
      leds[34] = CRGB::Black;
      leds[35] = CRGB::Black;
      leds[36] = CRGB::Black;
      leds[37] = CRGB::Black;
      leds[38] = CRGB::Black;
      leds[39] = CRGB::Black;
      leds[40] = CRGB::Black;
      leds[41] = CRGB::Black;
      leds[42] = CRGB::Black;
      leds[43] = CRGB::Black;
      leds[44] = CRGB::Black;
      leds[45] = CRGB::Black;
      leds[46] = CRGB::Black;
      leds[47] = CRGB::Black;
      leds[48] = CRGB::Black;
      leds[49] = CRGB::Black;
      leds[50] = CRGB::Black;
      leds[51] = CRGB::Black;
      leds[52] = CRGB::Black;
      leds[53] = CRGB::Black;
      leds[54] = CRGB::Black;
      leds[55] = CRGB::Black;
      leds[56] = CRGB::Black;
      leds[57] = CRGB::Black;
      leds[58] = CRGB::Black;
      leds[59] = CRGB::Black;
      leds[60] = CRGB::Black;
      leds[61] = CRGB::Black;
      leds[62] = CRGB::Black;
      leds[63] = CRGB::Black;


      // right tail light black

      leds[192] = CRGB::Black;
      leds[193] = CRGB::Black;
      leds[194] = CRGB::Black;
      leds[195] = CRGB::Black;
      leds[196] = CRGB::Black;
      leds[197] = CRGB::Black;
      leds[198] = CRGB::Black;
      leds[199] = CRGB::Black;
      leds[200] = CRGB::Black;
      leds[201] = CRGB::Black;
      leds[202] = CRGB::Black;
      leds[203] = CRGB::Black;
      leds[204] = CRGB::Black;
      leds[205] = CRGB::Black;
      leds[206] = CRGB::Black;
      leds[207] = CRGB::Black;
      leds[208] = CRGB::Black;
      leds[209] = CRGB::Black;
      leds[210] = CRGB::Black;
      leds[211] = CRGB::Black;
      leds[212] = CRGB::Black;
      leds[213] = CRGB::Black;
      leds[214] = CRGB::Black;
      leds[215] = CRGB::Black;
      leds[216] = CRGB::Black;
      leds[217] = CRGB::Black;
      leds[218] = CRGB::Black;
      leds[219] = CRGB::Black;
      leds[220] = CRGB::Black;
      leds[221] = CRGB::Black;
      leds[222] = CRGB::Black;
      leds[223] = CRGB::Black;
      leds[224] = CRGB::Black;
      leds[225] = CRGB::Black;
      leds[226] = CRGB::Black;
      leds[227] = CRGB::Black;
      leds[228] = CRGB::Black;
      leds[229] = CRGB::Black;
      leds[230] = CRGB::Black;
      leds[231] = CRGB::Black;
      leds[232] = CRGB::Black;
      leds[233] = CRGB::Black;
      leds[234] = CRGB::Black;
      leds[235] = CRGB::Black;
      leds[236] = CRGB::Black;
      leds[237] = CRGB::Black;
      leds[238] = CRGB::Black;
      leds[239] = CRGB::Black;
      leds[240] = CRGB::Black;
      leds[241] = CRGB::Black;
      leds[242] = CRGB::Black;
      leds[243] = CRGB::Black;
      leds[244] = CRGB::Black;
      leds[245] = CRGB::Black;
      leds[246] = CRGB::Black;
      leds[247] = CRGB::Black;
      leds[248] = CRGB::Black;
      leds[249] = CRGB::Black;
      leds[250] = CRGB::Black;
      leds[251] = CRGB::Black;
      leds[252] = CRGB::Black;
      leds[253] = CRGB::Black;
      leds[254] = CRGB::Black;
      leds[255] = CRGB::Black;

  


[/code :) ]
        // Turn the first led red for 1 second   leds[i] %= 192;
      leds[36]  = CRGB::Red;
       leds[35] = CRGB::Red;
       leds[28] = CRGB::Red;
       leds[27] = CRGB::Red;

       // left brake light
        leds[227] = CRGB::Red;
       leds[228] = CRGB::Red;
       leds[219] = CRGB::Red;
       leds[220] = CRGB::Red;









       
             FastLED.show();
      delay(200);

        // Turn the first led red for 1 second
      leds[42] = CRGB::Red;
       leds[43] = CRGB::Red;
       leds[44] = CRGB::Red;
       leds[45] = CRGB::Red;
       leds[37] = CRGB::Red;
       leds[29] = CRGB::Red;
       leds[21] = CRGB::Red;
       leds[20] = CRGB::Red;
        leds[19] = CRGB::Red;
       leds[18] = CRGB::Red;
       leds[26] = CRGB::Red;
        leds[34] = CRGB::Red;

        // left brake light 

        leds[234] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[210] = CRGB::Red;
       leds[211] = CRGB::Red;
        leds[212] = CRGB::Red;
       leds[213] = CRGB::Red;
       leds[218] = CRGB::Red;
        leds[229] = CRGB::Red;


        
             FastLED.show();
      delay(200);
      
  

  // Turn the first led red for 1 second
     
       leds[49] = CRGB::Red;
       leds[50] = CRGB::Red;
       leds[51] = CRGB::Red;
       leds[52] = CRGB::Red;
       leds[53] = CRGB::Red;
       leds[46] = CRGB::Red;
       leds[38] = CRGB::Red;
       leds[30] = CRGB::Red;
       leds[22] = CRGB::Red;
       leds[14] = CRGB::Red;
       leds[13] = CRGB::Red;
       leds[12] = CRGB::Red;
       leds[11] = CRGB::Red;
       leds[10] = CRGB::Red;
       leds[9] = CRGB::Red;
       leds[17] = CRGB::Red;
       leds[25] = CRGB::Red;
       leds[33] = CRGB::Red;
       leds[41] = CRGB::Red;
       leds[54] = CRGB::Red;


       // left brake light

       leds[241] = CRGB::Red;
       leds[242] = CRGB::Red;
       leds[243] = CRGB::Red;
       leds[244] = CRGB::Red;
       leds[245] = CRGB::Red;
       leds[246] = CRGB::Red;
       leds[233] = CRGB::Red;
       leds[230] = CRGB::Red;
       leds[217] = CRGB::Red;
       leds[214] = CRGB::Red;
       leds[201] = CRGB::Red;
       leds[202] = CRGB::Red;
       leds[203] = CRGB::Red;
       leds[204] = CRGB::Red;
       leds[205] = CRGB::Red;
       leds[206] = CRGB::Red;
       leds[209] = CRGB::Red;
       leds[222] = CRGB::Red;
       leds[225] = CRGB::Red;
       leds[238] = CRGB::Red;
       
       FastLED.show();
      delay(200);
      


        // Turn the first led red for 1 second
      leds[63] = CRGB::Red;
       leds[62] = CRGB::Red;
       leds[61] = CRGB::Red;
       leds[60] = CRGB::Red;
       leds[59] = CRGB::Red;
       leds[58] = CRGB::Red;
       leds[57] = CRGB::Red;
       leds[56] = CRGB::Red;
       leds[55] = CRGB::Red;
       leds[47] = CRGB::Red;
       leds[39] = CRGB::Red;
       leds[31] = CRGB::Red;
       leds[23] = CRGB::Red;
       leds[15] = CRGB::Red;
       leds[7] = CRGB::Red;
       leds[6] = CRGB::Red;
       leds[5] = CRGB::Red;
       leds[4] = CRGB::Red;
       leds[3] = CRGB::Red;
       leds[2] = CRGB::Red;
       leds[1] = CRGB::Red;
       leds[8] = CRGB::Red;
       leds[16] = CRGB::Red;
       leds[24] = CRGB::Red;
       leds[32] = CRGB::Red;
       leds[40] = CRGB::Red;
       leds[48] = CRGB::Red;
       leds[0] = CRGB::Red;

       // left brake light

       leds[255] = CRGB::Red;
       leds[254] = CRGB::Red;
       leds[253] = CRGB::Red;
       leds[252] = CRGB::Red;
       leds[251] = CRGB::Red;
       leds[250] = CRGB::Red;
       leds[249] = CRGB::Red;
       leds[248] = CRGB::Red;
       leds[247] = CRGB::Red;
       leds[232] = CRGB::Red;
       leds[231] = CRGB::Red;
       leds[216] = CRGB::Red;
       leds[215] = CRGB::Red;
       leds[200] = CRGB::Red;
       leds[199] = CRGB::Red;
       leds[198] = CRGB::Red;
       leds[197] = CRGB::Red;
       leds[196] = CRGB::Red;
       leds[195] = CRGB::Red;
       leds[194] = CRGB::Red;
       leds[193] = CRGB::Red;
       leds[192] = CRGB::Red;
       leds[207] = CRGB::Red;
       leds[208] = CRGB::Red;
       leds[223] = CRGB::Red;
       leds[224] = CRGB::Red;
       leds[239] = CRGB::Red;
       leds[240] = CRGB::Red;
       FastLED.show();
      delay(30);

   
oldButtonState3 == HIGH; // so this block can only run once

  }
//(buttonState3 == LOW && oldButtonState3 == HIGH)
  
 if(buttonState3 == LOW) {
  // "stop braking" code here
   // turn LED off:
   
FastLED.setBrightness(DIM);
      
      // Set the first led back to black for 1 second
      leds[0] = CRGB::Red;
      leds[1] = CRGB::Red;
      leds[2] = CRGB::Red;
      leds[3] = CRGB::Red;
      leds[4] = CRGB::Red;
      leds[5] = CRGB::Red;
      leds[6] = CRGB::Red;
      leds[7] = CRGB::Red;
      leds[8] = CRGB::Red;
      leds[9] = CRGB::Red;
      leds[10] = CRGB::Red;
      leds[11] = CRGB::Red;
      leds[12] = CRGB::Red;
      leds[13] = CRGB::Red;
      leds[14] = CRGB::Red;
      leds[15] = CRGB::Red;
      leds[16] = CRGB::Red;
      leds[17] = CRGB::Red;
      leds[18] = CRGB::Red;
      leds[19] = CRGB::Red;
      leds[20] = CRGB::Red;
      leds[21] = CRGB::Red;
      leds[22] = CRGB::Red;
      leds[23] = CRGB::Red;
      leds[24] = CRGB::Red;
      leds[25] = CRGB::Red;
      leds[26] = CRGB::Red;
      leds[27] = CRGB::Red;
      leds[28] = CRGB::Red;
      leds[29] = CRGB::Red;
      leds[30] = CRGB::Red;
      leds[31] = CRGB::Red;
      leds[32] = CRGB::Red;
      leds[33] = CRGB::Red;
      leds[34] = CRGB::Red;
      leds[35] = CRGB::Red;
      leds[36] = CRGB::Red;
      leds[37] = CRGB::Red;
      leds[38] = CRGB::Red;
      leds[39] = CRGB::Red;
      leds[40] = CRGB::Red;
      leds[41] = CRGB::Red;
      leds[42] = CRGB::Red;
      leds[43] = CRGB::Red;
      leds[44] = CRGB::Red;
      leds[45] = CRGB::Red;
      leds[46] = CRGB::Red;
      leds[47] = CRGB::Red;
      leds[48] = CRGB::Red;
      leds[49] = CRGB::Red;
      leds[50] = CRGB::Red;
      leds[51] = CRGB::Red;
      leds[52] = CRGB::Red;
      leds[53] = CRGB::Red;
      leds[54] = CRGB::Red;
      leds[55] = CRGB::Red;
      leds[56] = CRGB::Red;
      leds[57] = CRGB::Red;
      leds[58] = CRGB::Red;
      leds[59] = CRGB::Red;
      leds[60] = CRGB::Red;
      leds[61] = CRGB::Red;
      leds[62] = CRGB::Red;
      leds[63] = CRGB::Red;


      // left tail light black

      leds[192] = CRGB::Red;
      leds[193] = CRGB::Red;
      leds[194] = CRGB::Red;
      leds[195] = CRGB::Red;
      leds[196] = CRGB::Red;
      leds[197] = CRGB::Red;
      leds[198] = CRGB::Red;
      leds[199] = CRGB::Red;
      leds[200] = CRGB::Red;
      leds[201] = CRGB::Red;
      leds[202] = CRGB::Red;
      leds[203] = CRGB::Red;
      leds[204] = CRGB::Red;
      leds[205] = CRGB::Red;
      leds[206] = CRGB::Red;
      leds[207] = CRGB::Red;
      leds[208] = CRGB::Red;
      leds[209] = CRGB::Red;
      leds[210] = CRGB::Red;
      leds[211] = CRGB::Red;
      leds[212] = CRGB::Red;
      leds[213] = CRGB::Red;
      leds[214] = CRGB::Red;
      leds[215] = CRGB::Red;
      leds[216] = CRGB::Red;
      leds[217] = CRGB::Red;
      leds[218] = CRGB::Red;
      leds[219] = CRGB::Red;
      leds[220] = CRGB::Red;
      leds[221] = CRGB::Red;
      leds[222] = CRGB::Red;
      leds[223] = CRGB::Red;
      leds[224] = CRGB::Red;
      leds[225] = CRGB::Red;
      leds[226] = CRGB::Red;
      leds[227] = CRGB::Red;
      leds[228] = CRGB::Red;
      leds[229] = CRGB::Red;
      leds[230] = CRGB::Red;
      leds[231] = CRGB::Red;
      leds[232] = CRGB::Red;
      leds[233] = CRGB::Red;
      leds[234] = CRGB::Red;
      leds[235] = CRGB::Red;
      leds[236] = CRGB::Red;
      leds[237] = CRGB::Red;
      leds[238] = CRGB::Red;
      leds[239] = CRGB::Red;
      leds[240] = CRGB::Red;
      leds[241] = CRGB::Red;
      leds[242] = CRGB::Red;
      leds[243] = CRGB::Red;
      leds[244] = CRGB::Red;
      leds[245] = CRGB::Red;
      leds[246] = CRGB::Red;
      leds[247] = CRGB::Red;
      leds[248] = CRGB::Red;
      leds[249] = CRGB::Red;
      leds[250] = CRGB::Red;
      leds[251] = CRGB::Red;
      leds[252] = CRGB::Red;
      leds[253] = CRGB::Red;
      leds[254] = CRGB::Red;
      leds[255] = CRGB::Red;

      FastLED.show();

      delay(30);
      
      oldButtonState3 == LOW;

      FastLED.setBrightness(BRIGHTNESS);


  }
  
  }

Okay I couldn't post the whole code because only 9k character limit so it is in two parts

It keeps running the loop when I have all the black coding at the front.

It works fine when the black coding is not there.

Please edit your posts and change them to use code tags for the code. It will then appear in a reasonable size box with a scroll bar. It will still need to be across two posts, but I'm sure we can soon show you how to shrink it down to a reasonable size, and help with your original question.

For example

        // left brake light 

        leds[234] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[210] = CRGB::Red;
       leds[211] = CRGB::Red;
        leds[212] = CRGB::Red;
       leds[213] = CRGB::Red;
       leds[218] = CRGB::Red;
        leds[229] = CRGB::Red;

becomes

        // left brake light 

        for (int i = 234; i <= 229; i++) leds[i] = CRGB::Red;

Also do you rely need all those libraries? I can't see any of them being used apart from the Neopixel one.

The problem is all that superfluous verbiage makes it hard to see the actual code structure.

ho ly sh . . . .

     leds[0] = CRGB::Red;
. 
.
.
      leds[63] = CRGB::Red;

those 64 lines can be reduced to

for (int z = 0; z < 64; z++;) {
 leds[z] = CRGB::Red;
}

Same goes for all of those other monstrosities. No wonder your code is long.

And second that with 'wth is with all of those libraries', please explain your setup, what are all the things you are having the Arduino do.

I was trying to figure out how to group the LED's! Okay I will clean up the code and re-post!

Thanks for the help so far this is HUGE (pun intended haha)

#include "FastLED.h"

// fast led constants
#define DATA_PIN    3        // change to your data pin
#define COLOR_ORDER GRB      // if colors are mismatched; change this
#define NUM_LEDS    256          // change to the number of LEDs in your strip
#define FRAMES_PER_SECOND  120
#define LED_TYPE    WS2812B
#define BRIGHTNESS          200
#define DIM         10
#define ALL 0-255

const int buttonPin1 = 5;     // the number of the pushbutton pin
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 10;

// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int oldButtonState3 = 0;


// this creates an LED array to hold the values for each led in your strip
CRGB leds[NUM_LEDS];


void setup()
{
    delay(3000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  // the wiki features a much more basic setup line:
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

Serial.begin(9600);

// initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}

 void loop() 
{  // read the state of the pushbutton value:
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
  

  if(buttonState3 == HIGH && oldButtonState3 == LOW){

  // turn tail lights black quickly

for (int z = 0; z < 64; z++;) {
 leds[z] = CRGB::Black;
    for (int b = 192; z < 256; z++;) {
 leds[b] = CRGB::Black;
      FastLED.show();
      delay(200);

  // Turn the center 4 led red for 1 second
      leds[36]  = CRGB::Red;
       leds[35] = CRGB::Red;
       leds[28] = CRGB::Red;
       leds[27] = CRGB::Red;
//left brake light
        leds[227] = CRGB::Red;
       leds[228] = CRGB::Red;
       leds[219] = CRGB::Red;
       leds[220] = CRGB::Red;
      FastLED.show();
      delay(200);

        // Turn the next ring led red for 1 second
      leds[42] = CRGB::Red;
       leds[43] = CRGB::Red;
       leds[44] = CRGB::Red;
       leds[45] = CRGB::Red;
       leds[37] = CRGB::Red;
       leds[29] = CRGB::Red;
       leds[21] = CRGB::Red;
       leds[20] = CRGB::Red;
        leds[19] = CRGB::Red;
       leds[18] = CRGB::Red;
       leds[26] = CRGB::Red;
        leds[34] = CRGB::Red;

        // left brake light 

        leds[234] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[210] = CRGB::Red;
       leds[211] = CRGB::Red;
        leds[212] = CRGB::Red;
       leds[213] = CRGB::Red;
       leds[218] = CRGB::Red;
        leds[229] = CRGB::Red;
        FastLED.show();
       delay(200);
      
  

  // Turn the third ring led red for 1 second
     
       leds[49] = CRGB::Red;
       leds[50] = CRGB::Red;
       leds[51] = CRGB::Red;
       leds[52] = CRGB::Red;
       leds[53] = CRGB::Red;
       leds[46] = CRGB::Red;
       leds[38] = CRGB::Red;
       leds[30] = CRGB::Red;
       leds[22] = CRGB::Red;
       leds[14] = CRGB::Red;
       leds[13] = CRGB::Red;
       leds[12] = CRGB::Red;
       leds[11] = CRGB::Red;
       leds[10] = CRGB::Red;
       leds[9] = CRGB::Red;
       leds[17] = CRGB::Red;
       leds[25] = CRGB::Red;
       leds[33] = CRGB::Red;
       leds[41] = CRGB::Red;
       leds[54] = CRGB::Red;

       // left brake light
       leds[241] = CRGB::Red;
       leds[242] = CRGB::Red;
       leds[243] = CRGB::Red;
       leds[244] = CRGB::Red;
       leds[245] = CRGB::Red;
       leds[246] = CRGB::Red;
       leds[233] = CRGB::Red;
       leds[230] = CRGB::Red;
       leds[217] = CRGB::Red;
       leds[214] = CRGB::Red;
       leds[201] = CRGB::Red;
       leds[202] = CRGB::Red;
       leds[203] = CRGB::Red;
       leds[204] = CRGB::Red;
       leds[205] = CRGB::Red;
       leds[206] = CRGB::Red;
       leds[209] = CRGB::Red;
       leds[222] = CRGB::Red;
       leds[225] = CRGB::Red;
       leds[238] = CRGB::Red;
       FastLED.show();
      delay(200);
      
        // Turn the fourth ring red for 1 second
      leds[63] = CRGB::Red;
       leds[62] = CRGB::Red;
       leds[61] = CRGB::Red;
       leds[60] = CRGB::Red;
       leds[59] = CRGB::Red;
       leds[58] = CRGB::Red;
       leds[57] = CRGB::Red;
       leds[56] = CRGB::Red;
       leds[55] = CRGB::Red;
       leds[47] = CRGB::Red;
       leds[39] = CRGB::Red;
       leds[31] = CRGB::Red;
       leds[23] = CRGB::Red;
       leds[15] = CRGB::Red;
       leds[7] = CRGB::Red;
       leds[6] = CRGB::Red;
       leds[5] = CRGB::Red;
       leds[4] = CRGB::Red;
       leds[3] = CRGB::Red;
       leds[2] = CRGB::Red;
       leds[1] = CRGB::Red;
       leds[8] = CRGB::Red;
       leds[16] = CRGB::Red;
       leds[24] = CRGB::Red;
       leds[32] = CRGB::Red;
       leds[40] = CRGB::Red;
       leds[48] = CRGB::Red;
       leds[0] = CRGB::Red;

       // left brake light
       leds[255] = CRGB::Red;
       leds[254] = CRGB::Red;
       leds[253] = CRGB::Red;
       leds[252] = CRGB::Red;
       leds[251] = CRGB::Red;
       leds[250] = CRGB::Red;
       leds[249] = CRGB::Red;
       leds[248] = CRGB::Red;
       leds[247] = CRGB::Red;
       leds[232] = CRGB::Red;
       leds[231] = CRGB::Red;
       leds[216] = CRGB::Red;
       leds[215] = CRGB::Red;
       leds[200] = CRGB::Red;
       leds[199] = CRGB::Red;
       leds[198] = CRGB::Red;
       leds[197] = CRGB::Red;
       leds[196] = CRGB::Red;
       leds[195] = CRGB::Red;
       leds[194] = CRGB::Red;
       leds[193] = CRGB::Red;
       leds[192] = CRGB::Red;
       leds[207] = CRGB::Red;
       leds[208] = CRGB::Red;
       leds[223] = CRGB::Red;
       leds[224] = CRGB::Red;
       leds[239] = CRGB::Red;
       leds[240] = CRGB::Red;
       FastLED.show();
      delay(30);

   
oldButtonState3 == HIGH; // so this block can only run once

  }
  
 if(buttonState3 == LOW) {
  // "stop braking" code here
 
        // turn both tail light dim red
FastLED.setBrightness(DIM);
  
      leds[b] = CRGB::Red;
      leds[z] = CRGB::Red;      
FastLED.show();
  delay(30);
      
      oldButtonState3 == LOW;

      FastLED.setBrightness(BRIGHTNESS);


  }
  
  }

Better but still away to go.
When you have a load of LEDs that do not have consecutive numbers you use an other array as a list or look up table of these array numbers. So for example when you want to turn on the center four lights you first define the array that contains the numbers and then use the array contents as the LED array you want to change.

// outside of a function define:-
byte center4 = {36,35,28,27};

// then inside a function use
for (int b = 0; b<4; b++;) {
 leds[center4[b]] = CRGB::RED;
}

That will help a lot the longer the list goes on.

Can you explain why you need both center4 and b? Seems like center4 should already call out those numbers?

Also what does b++ mean?

Read up and watch some videos about 'for loops'. You need to understand it. You also seem to be missing a few closing brackets }

midwesta:
Can you explain why you need both center4 and b? Seems like center4 should already call out those numbers?

The variable center4 is an array, in C you need to access each element one at a time by using a sutiable index given in the square braces.

If you just used b then you would turn on just LEDs 0 to 3. As center4 is an array then the first element of that array returns 36. So center4[0] returns 36, that is the number of LED you want to turn on. The variable b is called the loop index that goes from zero to less than four which is 3.

Also what does b++ mean?

The operation ++ adds one to the variable it is placed next to. So b++ means what ever the value of b was, add one to it.

So here is a shorter version that works except:

The brake code is looping - I want button three to do the code once and stay bright until I release.

The blinkers are working good - EXCEPT I would like the non blinking light to stay at the 10 brightness (DIM)

#include "FastLED.h"

// fast led constants
#define DATA_PIN    3        // change to your data pin
#define COLOR_ORDER GRB      // if colors are mismatched; change this
#define NUM_LEDS    256          // change to the number of LEDs in your strip
#define FRAMES_PER_SECOND  120
#define LED_TYPE    WS2812B
#define BRIGHTNESS          200
#define DIM         10

// constant variables
const int buttonPin1 = 5;     // the number of the pushbutton pin
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 10;

// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int oldButtonState3 = 0;

// this creates an LED array to hold the values for each led in your strip
CRGB leds[NUM_LEDS];

void setup()
{
    delay(3000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  // the wiki features a much more basic setup line:
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

Serial.begin(9600);

// initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}

 void loop() 
{  
      FastLED.setBrightness(DIM);
      
// Set the right tail light to black for 1 second
      for (int i = 0; i <= 63; i++) 
              leds[i] = CRGB::Red;

// Set the left tail light to black for 1 second
      for (int j = 192; j <= 255; j++) 
             leds[j] = CRGB::Red;
              FastLED.show();
  
// read the state of the pushbutton value:
    buttonState1 = digitalRead(buttonPin1);
    buttonState2 = digitalRead(buttonPin2);
    buttonState3 = digitalRead(buttonPin3);
    buttonState4 = digitalRead(buttonPin4);
  




 // check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
          if (buttonState1 == HIGH) {


//LEFT TURN SIGNAL



// left tail light black 
        for (int j = 192; j <= 255; j++) 
              leds[j] = CRGB::Black;


        FastLED.setBrightness(BRIGHTNESS);
// Turn the first led red

        for (int a = 192; a <= 220; a++) 
        leds[a] = CRGB::Red;
        FastLED.show();
        delay(100);
      
// Set the first led back to black
        for (int a = 192; a <= 220; a++) 
        leds[a] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[207] = CRGB::Red;
       leds[209] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[227] = CRGB::Red;
       leds[228] = CRGB::Red;
       leds[218] = CRGB::Red;
       leds[214] = CRGB::Red;
       leds[200] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
      leds[207] = CRGB::Black;
      leds[209] = CRGB::Black;
      leds[221] = CRGB::Black;
      leds[227] = CRGB::Black;
      leds[228] = CRGB::Black;
      leds[218] = CRGB::Black;
      leds[214] = CRGB::Black;
      leds[200] = CRGB::Black;
      FastLED.show();
      delay(30);

// Turn the first led red for 1 second
       leds[208] = CRGB::Red;
       leds[222] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[229] = CRGB::Red;
       leds[217] = CRGB::Red;
       leds[215] = CRGB::Red;
       FastLED.show();
        delay(100);
      
// Set the first led back to black for 1 second
      leds[208] = CRGB::Black;
      leds[222] = CRGB::Black;
      leds[226] = CRGB::Black;
      leds[236] = CRGB::Black;
      leds[235] = CRGB::Black;
      leds[229] = CRGB::Black;
      leds[217] = CRGB::Black;
      leds[215] = CRGB::Black;
      FastLED.show();
      delay(30);

// Turn the first led red for 1 second
       leds[223] = CRGB::Red;
       leds[225] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[243] = CRGB::Red;
       leds[244] = CRGB::Red;
       leds[234] = CRGB::Red;
       leds[230] = CRGB::Red;
       leds[216] = CRGB::Red;
        FastLED.show();
        delay(100);
      
// Set the first led back to black for 1 second
      leds[223] = CRGB::Black;
      leds[225] = CRGB::Black;
      leds[237] = CRGB::Black;
      leds[243] = CRGB::Black;
      leds[244] = CRGB::Black;
      leds[234] = CRGB::Black;
      leds[230] = CRGB::Black;
      leds[216] = CRGB::Black;
      FastLED.show();
      delay(30);

// Turn the first led red for 1 second
       leds[224] = CRGB::Red;
       leds[238] = CRGB::Red;
       leds[242] = CRGB::Red;
       leds[252] = CRGB::Red;
       leds[251] = CRGB::Red;
       leds[245] = CRGB::Red;
       leds[233] = CRGB::Red;
       leds[231] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
      leds[224] = CRGB::Black;
      leds[238] = CRGB::Black;
      leds[242] = CRGB::Black;
      leds[252] = CRGB::Black;
      leds[251] = CRGB::Black;
      leds[245] = CRGB::Black;
      leds[233] = CRGB::Black;
      leds[231] = CRGB::Black;
      FastLED.show();
      delay(30);

      


  }

Second half of the code:

// RIGHT TURN SIGNAL

if (buttonState2 == HIGH) {

FastLED.setBrightness(BRIGHTNESS);
  
// Set the first led back to black for 1 second
        for (int i = 0; i <= 63; i++) 
            leds[i] = CRGB::Black;

// Turn the first led red for 1 second
       leds[56] = CRGB::Red;
       leds[57] = CRGB::Red;
       leds[58] = CRGB::Red;
       leds[59] = CRGB::Red;
       leds[60] = CRGB::Red;
       leds[61] = CRGB::Red;
       leds[62] = CRGB::Red;
       leds[63] = CRGB::Red;
       leds[49] = CRGB::Red;
       leds[50] = CRGB::Red;
       leds[51] = CRGB::Red;
       leds[52] = CRGB::Red;
       leds[53] = CRGB::Red;
       leds[54] = CRGB::Red;
       leds[42] = CRGB::Red;
       leds[43] = CRGB::Red;
       leds[44] = CRGB::Red;
       leds[45] = CRGB::Red;
       leds[35] = CRGB::Red;
       leds[36] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
       leds[56] = CRGB::Black;
       leds[57] = CRGB::Black;
       leds[58] = CRGB::Black;
       leds[59] = CRGB::Black;
       leds[60] = CRGB::Black;
       leds[61] = CRGB::Black;
       leds[62] = CRGB::Black;
       leds[63] = CRGB::Black;
       leds[49] = CRGB::Black;
       leds[50] = CRGB::Black;
       leds[51] = CRGB::Black;
       leds[52] = CRGB::Black;
       leds[53] = CRGB::Black;
       leds[54] = CRGB::Black;
       leds[42] = CRGB::Black;
       leds[43] = CRGB::Black;
       leds[44] = CRGB::Black;
       leds[45] = CRGB::Black;
       leds[35] = CRGB::Black;
       leds[36] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[48] = CRGB::Red;
       leds[55] = CRGB::Red;
       leds[46] = CRGB::Red;
       leds[41] = CRGB::Red;
       leds[37] = CRGB::Red;
       leds[34] = CRGB::Red;
       leds[28] = CRGB::Red;
       leds[27] = CRGB::Red;
       FastLED.show();
        delay(100);
      
// Set the first led back to black for 1 second
       leds[48] = CRGB::Black;
       leds[55] = CRGB::Black;
       leds[46] = CRGB::Black;
       leds[41] = CRGB::Black;
       leds[37] = CRGB::Black;
       leds[34] = CRGB::Black;
       leds[28] = CRGB::Black;
       leds[27] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[47] = CRGB::Red;
       leds[40] = CRGB::Red;
       leds[33] = CRGB::Red;
       leds[38] = CRGB::Red;
       leds[26] = CRGB::Red;
       leds[29] = CRGB::Red;
       leds[19] = CRGB::Red;
       leds[20] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
       leds[47] = CRGB::Black;
       leds[40] = CRGB::Black;
       leds[33] = CRGB::Black;
       leds[38] = CRGB::Black;
       leds[26] = CRGB::Black;
       leds[29] = CRGB::Black;
       leds[19] = CRGB::Black;
       leds[20] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[39] = CRGB::Red;
       leds[32] = CRGB::Red;
       leds[25] = CRGB::Red;
       leds[30] = CRGB::Red;
       leds[21] = CRGB::Red;
       leds[18] = CRGB::Red;
       leds[12] = CRGB::Red;
       leds[11] = CRGB::Red;
             FastLED.show();
      delay(100);
      
 // Set the first led back to black for 1 second
      leds[39] = CRGB::Black;
       leds[32] = CRGB::Black;
       leds[25] = CRGB::Black;
       leds[30] = CRGB::Black;
       leds[21] = CRGB::Black;
       leds[18] = CRGB::Black;
       leds[12] = CRGB::Black;
       leds[11] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[31] = CRGB::Red;
       leds[24] = CRGB::Red;
       leds[22] = CRGB::Red;
       leds[17] = CRGB::Red;
       leds[13] = CRGB::Red;
       leds[10] = CRGB::Red;
       leds[4] = CRGB::Red;
       leds[3] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
      leds[31] = CRGB::Black;
      leds[24] = CRGB::Black;
      leds[22] = CRGB::Black;
      leds[17] = CRGB::Black;
      leds[13] = CRGB::Black;
      leds[10] = CRGB::Black;
      leds[4] = CRGB::Black;
      leds[3] = CRGB::Black;
      FastLED.show();
      delay(30);

  }

Needed a third :frowning:

//BRAKE LIGHT
       FastLED.setBrightness(BRIGHTNESS);
      if(buttonState3 == HIGH){
// Set the right tail light black
        for (int i = 0; i <= 63; i++) 
              leds[i] = CRGB::Black;
              
// left tail light black
        for (int j = 192; j <= 255; j++) 
            leds[j] = CRGB::Black;
              FastLED.show();
              delay(200);

// Turn the first led red for 1 second   leds[i] %= 192;
       leds[36]  = CRGB::Red;
       leds[35] = CRGB::Red;
       leds[28] = CRGB::Red;
       leds[27] = CRGB::Red;

// left brake light
       leds[227] = CRGB::Red;
       leds[228] = CRGB::Red;
       leds[219] = CRGB::Red;
       leds[220] = CRGB::Red;
        FastLED.show();
        delay(200);
        
// Turn the first led red for 1 second
       leds[42] = CRGB::Red;
       leds[43] = CRGB::Red;
       leds[44] = CRGB::Red;
       leds[45] = CRGB::Red;
       leds[37] = CRGB::Red;
       leds[29] = CRGB::Red;
       leds[21] = CRGB::Red;
       leds[20] = CRGB::Red;
       leds[19] = CRGB::Red;
       leds[18] = CRGB::Red;
       leds[26] = CRGB::Red;
       leds[34] = CRGB::Red;

// left brake light 
       leds[234] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[210] = CRGB::Red;
       leds[211] = CRGB::Red;
       leds[212] = CRGB::Red;
       leds[213] = CRGB::Red;
       leds[218] = CRGB::Red;
       leds[229] = CRGB::Red;
        FastLED.show();
        delay(200);
      
// Turn the first led red for 1 second
       leds[49] = CRGB::Red;
       leds[50] = CRGB::Red;
       leds[51] = CRGB::Red;
       leds[52] = CRGB::Red;
       leds[53] = CRGB::Red;
       leds[46] = CRGB::Red;
       leds[38] = CRGB::Red;
       leds[30] = CRGB::Red;
       leds[22] = CRGB::Red;
       leds[14] = CRGB::Red;
       leds[13] = CRGB::Red;
       leds[12] = CRGB::Red;
       leds[11] = CRGB::Red;
       leds[10] = CRGB::Red;
       leds[9] = CRGB::Red;
       leds[17] = CRGB::Red;
       leds[25] = CRGB::Red;
       leds[33] = CRGB::Red;
       leds[41] = CRGB::Red;
       leds[54] = CRGB::Red;

// left brake light
       leds[241] = CRGB::Red;
       leds[242] = CRGB::Red;
       leds[243] = CRGB::Red;
       leds[244] = CRGB::Red;
       leds[245] = CRGB::Red;
       leds[246] = CRGB::Red;
       leds[233] = CRGB::Red;
       leds[230] = CRGB::Red;
       leds[217] = CRGB::Red;
       leds[214] = CRGB::Red;
       leds[201] = CRGB::Red;
       leds[202] = CRGB::Red;
       leds[203] = CRGB::Red;
       leds[204] = CRGB::Red;
       leds[205] = CRGB::Red;
       leds[206] = CRGB::Red;
       leds[209] = CRGB::Red;
       leds[222] = CRGB::Red;
       leds[225] = CRGB::Red;
       leds[238] = CRGB::Red;  
        FastLED.show();
         delay(200);
      
// Turn the first led red for 1 second
       leds[63] = CRGB::Red;
       leds[62] = CRGB::Red;
       leds[61] = CRGB::Red;
       leds[60] = CRGB::Red;
       leds[59] = CRGB::Red;
       leds[58] = CRGB::Red;
       leds[57] = CRGB::Red;
       leds[56] = CRGB::Red;
       leds[55] = CRGB::Red;
       leds[47] = CRGB::Red;
       leds[39] = CRGB::Red;
       leds[31] = CRGB::Red;
       leds[23] = CRGB::Red;
       leds[15] = CRGB::Red;
       leds[7] = CRGB::Red;
       leds[6] = CRGB::Red;
       leds[5] = CRGB::Red;
       leds[4] = CRGB::Red;
       leds[3] = CRGB::Red;
       leds[2] = CRGB::Red;
       leds[1] = CRGB::Red;
       leds[8] = CRGB::Red;
       leds[16] = CRGB::Red;
       leds[24] = CRGB::Red;
       leds[32] = CRGB::Red;
       leds[40] = CRGB::Red;
       leds[48] = CRGB::Red;
       leds[0] = CRGB::Red;
       
// left brake light
       leds[255] = CRGB::Red;
       leds[254] = CRGB::Red;
       leds[253] = CRGB::Red;
       leds[252] = CRGB::Red;
       leds[251] = CRGB::Red;
       leds[250] = CRGB::Red;
       leds[249] = CRGB::Red;
       leds[248] = CRGB::Red;
       leds[247] = CRGB::Red;
       leds[232] = CRGB::Red;
       leds[231] = CRGB::Red;
       leds[216] = CRGB::Red;
       leds[215] = CRGB::Red;
       leds[200] = CRGB::Red;
       leds[199] = CRGB::Red;
       leds[198] = CRGB::Red;
       leds[197] = CRGB::Red;
       leds[196] = CRGB::Red;
       leds[195] = CRGB::Red;
       leds[194] = CRGB::Red;
       leds[193] = CRGB::Red;
       leds[192] = CRGB::Red;
       leds[207] = CRGB::Red;
       leds[208] = CRGB::Red;
       leds[223] = CRGB::Red;
       leds[224] = CRGB::Red;
       leds[239] = CRGB::Red;
       leds[240] = CRGB::Red;
        FastLED.show();
        delay(30);

   
        oldButtonState3 = HIGH; // so this block can only run once

}

// "stop braking" code here
// turn LED off:
          if(buttonState3 == LOW) {
        delay(30);
      
          oldButtonState3 == LOW;
          FastLED.setBrightness(BRIGHTNESS);

  }
 

}

This is heavy going.

The reply #15 was to show you how to light LEDs in a loop where the LED number do not follow each other but are in an arbitrary sequence. I gave you one short example. I expected you to apply that technique to all the rest of the turged code you had, so you did not need three posts to get your code over.