# Addressable LED lighting part of a row

I've tried and tried. Is there a easier way to light up part of a row of LED's than this?

``````if (digitalRead(BUTTON_INPUT) == LOW) {
LeftStrip[2] = CHSV(200, 255, 255);
LeftStrip[3] = CHSV(200, 255, 255);
LeftStrip[4] = CHSV(200, 255, 255);
LeftStrip[5] = CHSV(200, 255, 255);
FastLED.show();}
``````

Something like a one liner:

"LeftStrip[2 thur 5] = CHSV(200, 255, 255);"

to replace all 4 lines with one line.

I'm using 2811's and a NodeMCU

Research on “for loops”.

Hang on! LMGTFY!

Paul__B:
Research on “for loops”.

Hang on! LMGTFY!

I using for loops in other parts of the code doing [LED + 1] and so on. I didn’t include the whole code because it’s really long and my question only pertained to these few lines. So, a for loop is going to be the easiest way to do it? I thought maybe there was a really simple way like

`````` LeftStrip [LED2,, 18]  = CHSV(200, 255, 255);

// I have used something like this before:

(int LED = 2; LED <= 18; LED = LED +1)
LeftStrip[LED] = CHSV(200, 255, 255);
FastLED.show();}
``````

What you have done there is a for loop, except you got it slightly wrong. Try:

``````if (digitalRead(BUTTON_INPUT) == LOW) {
for (int LED = 2; LED <= 18; LED++) LeftStrip[LED] = CHSV(200, 255, 255);
FastLED.show();
}
``````

PaulRB:
What you have done there is a for loop, except you got it slightly wrong. Try:

``````if (digitalRead(BUTTON_INPUT) == LOW) {
``````

for (int LED = 2; LED <= 18; LED++) LeftStrip[LED] = CHSV(200, 255, 255);
FastLED.show();
}

I see, I forgot my “for”. Thanks for the help. I was just looking for another way. I’ll wrap my brain around using for looks to control what lights do what when I want to turn on a “set” in a strip. I’m doing the same thing now in my sequential strips. I’m just doing the whole strip and using delays. This is the same thing just starting and ending in the middle of a strip and with no delay. I think I’ve got a grasp on it now. Thanks again!!!