Multiple Buttons independently controlling groups of LEDs in a single strand

I now have two buttons ‘working’ without having to define each LED separately. Thank you for the help with that.

But now I have a flickering problem!

If I press the button1 LEDs behave as expected in both HIGH and LOW position.
If I press button2 the next set of LEDs turn red BUT the preceding LEDs take on a pink flicker

Press and hold Button 1 and button two quits working.
Press and Hold Button 2 and button1 works but with the pink flicker when it should be white.

Is there a way to have each of these sections operate independently, So that pressing one does not effect the others? This project will have 14 different ‘zones’ when complete.

I know that there is no simultaneous computing with an Arduino but there has to be a way to use multiple buttons at the same time.

#include <FastLED.h>
#define NUM_LEDS 55
#define DATA_PIN 10
CRGB leds[NUM_LEDS];

// constants won't change. They're used here to set pin numbers:
const int RightF = 2;     // pin number of the burner relay 
const int RightR = 3;     // pin number of the burner relay 
#define WW CRGB(225,200,25)
#define RED1 CRGB(225,0,0)
#define RightSide         (i=0; i<5; i++)
#define RightFront        (i=5; i<9; i++)


int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;         
int i;                     

void setup() {
   FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); 
   
  // initialize the pushbutton pin as an input:
  pinMode(RightF, INPUT_PULLUP);  // setting burner locations to pullup 
  pinMode(RightR, INPUT_PULLUP);  // 
  
  
}

void loop() {
  bool ledsOn;
  // read the state of the pushbutton value:
  buttonState1 = digitalRead(RightF);
  buttonState2 = digitalRead(RightR);

  ledsOn = false;
  
  // Right Side 
    // Low Turns LEDS 0-3 RED1
      if (buttonState1 == LOW) {
        for RightSide{
          fill_solid (leds, i, RED1);  
            }
       FastLED.show();
       ledsOn = true;
        } 

     // High turns LEDS 0-3 WW
       if (buttonState1 == HIGH) {
        for RightSide{
          fill_solid (leds, i, WW);  
            }
    FastLED.show();
    ledsOn = true;

    ledsOn = false;
  
  // Right Front
    // Low Turns LEDS 0-3 RED1
      if (buttonState2 == LOW) {
        for RightFront{
          fill_solid (leds, i, RED1);  
            }
       FastLED.show();
       ledsOn = true;
        } 

     // High turns LEDS 0-3 WW
       if (buttonState2 == HIGH) {
        for RightFront{
          fill_solid (leds, i, WW);  
            }
    FastLED.show();
    ledsOn = true;

      if (!ledsOn){
    // turn all back to warm white after burner is off :
    fill_solid (leds,NUM_LEDS, CRGB(225,200,25));
     FastLED.show();
  }
}
}
}/code]

Those three curly braces in a row on the left edge shows the code is not formatted correctly. In the IDE choose Tools=>Auto Format to fix the formatting then look closely here:

  // High turns LEDS 0-3 WW
  if (buttonState1 == HIGH) {
    for RightSide{
    fill_solid (leds, i, WW);
    }
    FastLED.show();
    ledsOn = true;

    ledsOn = false;

    // Right Front
    // Low Turns LEDS 0-3 RED1
    if (buttonState2 == LOW) {

The state of button2 is not considered unless button1 is HIGH, which explains why button 2 stops responding if button 1 is held down.

Also, you should remove the line in above that sets ledsOn to false and you have another curly brace to move so that the check of ledsOn is outside the button check code.

Oh, dear Lord, NO

#define RightSide         (i=0; i<5; i++)
#define RightFront        (i=5; i<9; i++)

Also, the root of your fickering problem is that you are not using

fill_solid (leds, i, WW);

correctly. Every time through the loop, i is incremented and you are requesting to the fill_solid() function to only fill that many LEDs with the given color. What exactly are you trying to do?

I believe that I have corrected the logic in a similar thread. Moderator might want to consider combining.

Thank you Todd! your other post was excellent! Worked like a charm.

The key is assigning everything first and then putting FastLED.show(); last.

it reads it all first and then shows it! Fantastic

Here is link to the other post for anyone as lost as I was