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]