IR NeoPixel project

Hello, I'm hoping someone would be able to help me with an issue i've been having trying to make an IR LED project. I've got 3 LED strips being controlled off the same remote and i'd like to be able to control them individually, by pressing a certain button on the controller (DIY1, hex 0xFF30CF) which will then allow me to control strip one, and use the colours on the remote exclusively for this strip, and then when I select strip 2 using the 'DIY2', (hex 0xFFB04F) button on the remote, it allow exclusive access to strip two, and the same again for strip 3

Below is the code i've started, I understand how to control the strips if there was only one, or all together (by adding a command underneath the relevant button), but i'm struggling to work out how to split the strips into sections and control them individually. Any help is much appreciated!

#include <IRremote.h> //include IR library
#include <FastLED.h> //include LED library
#define NUM_LEDS1 18 //say how many leds is in row 1
#define NUM_LEDS2 18 //say how many leds is in row 2
#define NUM_LEDS3 18 //say how many leds is in row 3
#define ROW1DATA 5 //say what pin is signal for row 1
#define ROW2DATA 3 //say what pin is signal for row 2
#define ROW3DATA 6 //say what pin is signal for row 3
const int RECV_PIN = 8; //say what pin IR sensor is plugged into
const int LEDPIN = 13;//say what pin blue STATUS led is plugged into
IRrecv irrecv(RECV_PIN); // IR
decode_results results; // IR
unsigned long key_value = 0; // IR
CRGB leds1[NUM_LEDS1]; //link leds1 with how many leds are in it
CRGB leds2[NUM_LEDS2]; //link leds2 with how many leds are in it
CRGB leds3[NUM_LEDS3]; //link leds3 with how many leds are in it

void setup(){
  Serial.begin(9600); //set baud rate for serial monitor
  irrecv.enableIRIn(); // IR
  irrecv.blink13(true); // IR
  pinMode(LEDPIN, OUTPUT); //set signal led as an output
  FastLED.addLeds<NEOPIXEL, ROW1DATA>(leds1, NUM_LEDS1); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW2DATA>(leds2, NUM_LEDS2); //setup for row 2
  FastLED.addLeds<NEOPIXEL, ROW3DATA>(leds3, NUM_LEDS3); //setup for row 3
}

void loop(){
  if (irrecv.decode(&results)){
 
        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){
          case 0xFF02FD:
          Serial.println("ON/OFF");
          break ;
          case 0xFF827D:
          Serial.println("PAUSE");
          break ;
          case 0xFFBA45:
          Serial.println("LOWERBRIGHTNESS");
          break ;
          case 0xFF3AC5:
          Serial.println("RAISEBRIGHTNESS");
          break ;
          case 0xFF22DD:
          Serial.println("PUREWHITE");
          break ;
          case 0xFFA25D:
          Serial.println("PUREBLUE");
          break ;
          case 0xFF9A65:
          Serial.println("PUREGREEN");
          break ;
          case 0xFF1AE5:
          Serial.println("PURERED");
          break ;
          case 0xFF12ED:
          Serial.println("PUREPINK");
          break ;
          case 0xFF926D:
          Serial.println("DARKBLUE");
          break ;
          case 0xFFAA55:
          Serial.println("LIGHTGREEN");
          break ;
          case 0xFF2AD5:
          Serial.println("LIGHTRED");
          break ;
          case 0xFF32CD:
          Serial.println("LIGHTPINK");
          break ;
          case 0xFFB24D:
          Serial.println("DARKPURPLE");
          break ;
          case 0xFF8A75:
          Serial.println("LIGHTTURQUIOISE");
          break ;
          case 0xFF0AF5:
          Serial.println("ORANGE");
          break ;
          case 0xFFF807:
          Serial.println("LIGHTBLUE");
          break ;
          case 0xFF7887:
          Serial.println("PURPLE");
          break ;
          case 0xFFB847:
          Serial.println("DARKTURQUIOISE");
          break ;
          case 0xFF38C7:
          Serial.println("LIGHTORANGE");
          break ;
          case 0xFFD827:
          Serial.println("LIGHTESTBLUE");
          break ;
          case 0xFF58A7:
          Serial.println("LIGHTPURPLE");
          break ;
          case 0xFF9867:
          Serial.println("DARKESTTURQUOISE");
          break ;
          case 0xFF18E7:
          Serial.println("YELLOW");
          break ;
          case 0xFFE817:
          Serial.println("QUICK");
          break ;
          case 0xFF6897:
          Serial.println("BLUEUPARROW");
          break ;
          case 0xFFA857:
          Serial.println("GREENUPARROW");
          break ;
          case 0xFF28D7:
          Serial.println("REDUPARROW");
          break ;
          case 0xFFC837:
          Serial.println("SLOW");
          break ;
          case 0xFF48B7:
          Serial.println("BLUEDOWNARROW");
          break ;
          case 0xFF8877:
          Serial.println("GREENDOWNARROW");
          break ;
          case 0xFF08F7:
          Serial.println("REDDOWNARROW");
          break ;
          case 0xFFF00F:
          Serial.println("AUTO");
          break ;
          case 0xFF708F:
          Serial.println("DIY3");
          break ;
          case 0xFFB04F:
          Serial.println("DIY2");
          break ;
          case 0xFF30CF:
          Serial.println("DIY1");
          break ;
          case 0xFFD02F:
          Serial.println("FLASH");
          break ;
          case 0xFF50AF:
          Serial.println("DIY6");
          break ;
          case 0xFF906F:
          Serial.println("DIY5");
          break ;
          case 0xFF10EF:
          Serial.println("DIY4");
          break ;
          case 0xFFE01F:
          Serial.println("FADE7");
          break ;
          case 0xFF609F:
          Serial.println("FADE3");
          break ;
          case 0xFFA05F:
          Serial.println("JUMP7");
          break ;
          case 0xFF20DF:
          Serial.println("JUMP3");
          break ;
        }
        key_value = results.value;
        irrecv.resume();
  }
 }

Thank you!

Create a variable say stripNumber and put code under DIY1, 2, 3 to set it to the appropriate value.

In all the other cases, the routines that actually send commands to the strips, check stripNumber and send the command just to that strip. I'd probably do that by making a single function which handles the commands and give it 2 parameters, the specific command and the strip number.

Steve

Thanks for the response. I think I understand, however would that work since the buttons will be pressed at (albeit only slightly) different times, and won’t both be pressed simultaneously? E.g the time it takes for me to select DIY1, then select a colour?
Thanks,

Tom

Yes, it would work. The arduino code would remember which of the "diy" buttons was last pressed. It would know, when a colour button is pressed, which strip the change should be applied to. It would remember this as long as the arduino is powered. Or even longer, if that was important.

Hello,

Thank you for your reply, apologies on the delay I haven't had time from work to work on the project.

So, I've tried to implement what you said, see below:

#include <IRremote.h> //include IR library
#include <Arduino.h>
#include <FastLED.h> //include LED library
#define NUM_LEDS1 18 //say how many leds is in row 1
#define NUM_LEDS2 18 //say how many leds is in row 2
#define NUM_LEDS3 18 //say how many leds is in row 3
#define ROW1DATA 5 //say what pin is signal for row 1
#define ROW2DATA 3 //say what pin is signal for row 2
#define ROW3DATA 6 //say what pin is signal for row 3
const int RECV_PIN = 8; //say what pin IR sensor is plugged into
const int LEDPIN = 13;//say what pin blue STATUS led is plugged into
IRrecv irrecv(RECV_PIN); //something for IR
decode_results results; //something for IR
unsigned long key_value = 0; //something for IR
CRGB leds1[NUM_LEDS1]; //link leds1 with how many leds are in it
CRGB leds2[NUM_LEDS2]; //link leds2 with how many leds are in it
CRGB leds3[NUM_LEDS3]; //link leds3 with how many leds are in it
bool DIY1 = false;

void setup(){
  Serial.begin(9600); //set baud rate for serial monitor
  irrecv.enableIRIn(); //something for IR
  irrecv.blink13(true); //something for IR
  pinMode(LEDPIN, OUTPUT); //set signal led as an ourput
  FastLED.addLeds<NEOPIXEL, ROW1DATA>(leds1, NUM_LEDS1); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW2DATA>(leds2, NUM_LEDS2); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW3DATA>(leds3, NUM_LEDS3); //setup for row 1
  
}

void loop(){
boolstuff();
remote();
    }

void boolstuff(){// This function sets the variable of 'DIY1' as true if the button on the remote (suprisingly, DIY1) is pressed
  if (irrecv.decode(&results)){

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){

         case 0xFF30CF:
         DIY1 = true;
         break; 
        }
          key_value = results.value;
        irrecv.resume();
        }
}
    void remote (){ //This function checks if the variable of DIY1 has been pressed, and if it is NOT (e.g. value = false), it sets the LED strip to pulse blue, if it hasn't been, it pulses green
      
 if (irrecv.decode(&results)){

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){

         
        case 0xFF02FD:
  if(DIY1 = false)
        {
                Serial.println("shiftfalse");
         fill_solid( leds2, NUM_LEDS2, CRGB::Blue);
         FastLED.show();
         delay(500) ;
         fill_solid( leds2, NUM_LEDS2, CRGB::Black);
         FastLED.show();
         delay(500);
          }
else 
        {
              Serial.println("shifttrue");
         fill_solid( leds1, NUM_LEDS1, CRGB::Green);
         FastLED.show();
         delay(500) ;
         fill_solid( leds1, NUM_LEDS1, CRGB::Black);
         FastLED.show();
         delay(500);
            DIY1=false;  //reset the variable for next time, so it isn't latched
            break;      
         }
  }
  key_value = results.value;
        irrecv.resume();
    }
    }

So firstly as recommended, i've split the two function areas (the button pressing and the led strip commands), and am using a variable to tell the latter function when the pre-cursor button has been pressed. If it has been pressed, and is followed by another button on the remote it (should) tells the strip to display a pulsing green colour, and write a message on the serial monitor saying that the button both buttons have been pressed. If the pre-cursor button isn't pressed it should display a pulsing blue colour.

Except for some reason it doesn't work. It always displays the green colour and message, as though 'DIY1' has been pressed before, even if it hasn't.

I'm absolutely lost, if anyone has any guidance that would be much appreciated and will save me more hours of hair pulling!

Thanks,

Tom

Testing a value uses ==. You have "if (DIY1 = false)" which will SET DIY1 to false. Very common mistake.

Steve

You life saver, works a charm! Issue i'm having however is there is quite a delay between me pressing buttons on the remote, and the serial monitor (and LEDs) noticing... I know that its not a hardware issue because I have the built in LED set to flash when an input is read by the receiver, and it flashes instantly.

I've attached the update code below, but i'm struggling to see what is causing the delay, I haven't got any delays coded in at all, could it possibly be just taking a while to read through all the code? is there a way to reformat it if this is the case?

#include <IRremote.h> //include IR library
#include <Arduino.h>
#include <FastLED.h> //include LED library
#define NUM_LEDS1 18 //say how many leds is in row 1
#define NUM_LEDS2 18 //say how many leds is in row 2
#define NUM_LEDS3 18 //say how many leds is in row 3
#define ROW1DATA 5 //say what pin is signal for row 1
#define ROW2DATA 3 //say what pin is signal for row 2
#define ROW3DATA 6 //say what pin is signal for row 3
const int RECV_PIN = 8; //say what pin IR sensor is plugged into
const int LEDPIN = 13;//say what pin blue STATUS led is plugged into
IRrecv irrecv(RECV_PIN); //something for IR
decode_results results; //something for IR
unsigned long key_value = 0; //something for IR
CRGB leds1[NUM_LEDS1]; //link leds1 with how many leds are in it
CRGB leds2[NUM_LEDS2]; //link leds2 with how many leds are in it
CRGB leds3[NUM_LEDS3]; //link leds3 with how many leds are in it
bool DIY1 = false;
bool DIY2 = false;
bool DIY3 = false;

void setup(){
  Serial.begin(9600); //set baud rate for serial monitor
  irrecv.enableIRIn(); //Enables IR
  irrecv.blink13(true); //Flashes onboard LED when IR input detected
  pinMode(LEDPIN, OUTPUT); //set signal led as an ourput
  FastLED.addLeds<NEOPIXEL, ROW1DATA>(leds1, NUM_LEDS1); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW2DATA>(leds2, NUM_LEDS2); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW3DATA>(leds3, NUM_LEDS3); //setup for row 1
  
}

void loop(){
DIYbuttons();
strip1();
strip2();
strip3();
    }

void DIYbuttons(){
  if (irrecv.decode(&results)){

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){

         case 0xFF30CF:
         DIY1 = true;
         Serial.println("strip1_shift_pressed");
         break; 
         case 0xFFB04F:
         DIY2 = true;
         Serial.println("strip2_shift_pressed");
         break; 
         case 0xFF708F:
         DIY3 = true;
         Serial.println("strip3_shift_pressed");
         break; 
         
        }
          key_value = results.value;
        irrecv.resume();
        }
}
    void strip1 (){
      
 if (irrecv.decode(&results)){

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){

         
        case 0xFF1AE5:
  if(DIY1 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Red");
         fill_solid( leds1, NUM_LEDS1, CRGB::Red);
         FastLED.show();
         DIY1=false;  //reset the flag for next time
            break;      
         }
         case 0xFF9A65:
  if(DIY1 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Green");
         fill_solid( leds1, NUM_LEDS1, CRGB::Green);
         FastLED.show();
         DIY1=false;  //reset the flag for next time
            break;      
         }
         case 0xFFA25D:
  if(DIY1 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Blue");
         fill_solid( leds1, NUM_LEDS1, CRGB::Blue);
         FastLED.show();
         DIY1=false;  //reset the flag for next time
            break;      
         }
  }
  key_value = results.value;
        irrecv.resume();
    }
    }
    void strip2 (){
      
 if (irrecv.decode(&results)){

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){

         
       case 0xFF1AE5:
  if(DIY2 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Red");
         fill_solid( leds2, NUM_LEDS2, CRGB::Red);
         FastLED.show();
         DIY2=false;  //reset the flag for next time
            break;      
         }
         case 0xFF9A65:
  if(DIY2 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Green");
         fill_solid( leds2, NUM_LEDS2, CRGB::Green);
         FastLED.show();
         DIY2=false;  //reset the flag for next time
            break;      
         }
         case 0xFFA25D:
  if(DIY2 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Blue");
         fill_solid( leds2, NUM_LEDS2, CRGB::Blue);
         FastLED.show();
         DIY2=false;  //reset the flag for next time
            break;      
         }
  }
  key_value = results.value;
        irrecv.resume();
    }
    }
    void strip3 (){
      
 if (irrecv.decode(&results)){

        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){

         
        case 0xFF1AE5:
  if(DIY3 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Red");
         fill_solid( leds3, NUM_LEDS3, CRGB::Red);
         FastLED.show();
         DIY3=false;  //reset the flag for next time
            break;      
         }
         case 0xFF9A65:
  if(DIY3 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Green");
         fill_solid( leds3, NUM_LEDS3, CRGB::Green);
         FastLED.show();
         DIY3=false;  //reset the flag for next time
            break;      
         }
         case 0xFFA25D:
  if(DIY3 == false) //as before we started with this shift stuff
        {
                Serial.println("Select a strip first!");
        }
else // and here shift must be true cos it can only be false or true
        {
              Serial.println("Blue");
         fill_solid( leds3, NUM_LEDS3, CRGB::Blue);
         FastLED.show();
         DIY3=false;  //reset the flag for next time
            break;      
         }
  }
  key_value = results.value;
        irrecv.resume();
    }
    }

Many thanks,

Tom

Please auto-format that code and re-post it. It is almost unreadable.

Apologies, I wasn't even aware that was a thing! Thanks for pointing it out.

Please see a formatted version below :slight_smile:

#include <IRremote.h> //include IR library
#include <Arduino.h>
#include <FastLED.h> //include LED library
#define NUM_LEDS1 18 //say how many leds is in row 1
#define NUM_LEDS2 18 //say how many leds is in row 2
#define NUM_LEDS3 18 //say how many leds is in row 3
#define ROW1DATA 5 //say what pin is signal for row 1
#define ROW2DATA 3 //say what pin is signal for row 2
#define ROW3DATA 6 //say what pin is signal for row 3
const int RECV_PIN = 8; //say what pin IR sensor is plugged into
const int LEDPIN = 13;//say what pin blue STATUS led is plugged into
IRrecv irrecv(RECV_PIN); //something for IR
decode_results results; //something for IR
unsigned long key_value = 0; //something for IR
CRGB leds1[NUM_LEDS1]; //link leds1 with how many leds are in it
CRGB leds2[NUM_LEDS2]; //link leds2 with how many leds are in it
CRGB leds3[NUM_LEDS3]; //link leds3 with how many leds are in it
bool DIY1 = false;
bool DIY2 = false;
bool DIY3 = false;

void setup() {
  Serial.begin(9600); //set baud rate for serial monitor
  irrecv.enableIRIn(); //Enables IR
  irrecv.blink13(true); //Flashes onboard LED when IR input detected
  pinMode(LEDPIN, OUTPUT); //set signal led as an ourput
  FastLED.addLeds<NEOPIXEL, ROW1DATA>(leds1, NUM_LEDS1); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW2DATA>(leds2, NUM_LEDS2); //setup for row 1
  FastLED.addLeds<NEOPIXEL, ROW3DATA>(leds3, NUM_LEDS3); //setup for row 1

}

void loop() {
  DIYbuttons();
  strip1();
  strip2();
  strip3();
}

void DIYbuttons() {
  if (irrecv.decode(&results)) {

    if (results.value == 0XFFFFFFFF)
      results.value = key_value;

    switch (results.value) {

      case 0xFF30CF:
        DIY1 = true;
        Serial.println("strip1_shift_pressed");
        break;
      case 0xFFB04F:
        DIY2 = true;
        Serial.println("strip2_shift_pressed");
        break;
      case 0xFF708F:
        DIY3 = true;
        Serial.println("strip3_shift_pressed");
        break;

    }
    key_value = results.value;
    irrecv.resume();
  }
}
void strip1 () {

  if (irrecv.decode(&results)) {

    if (results.value == 0XFFFFFFFF)
      results.value = key_value;

    switch (results.value) {


      case 0xFF1AE5:
        if (DIY1 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Red");
          fill_solid( leds1, NUM_LEDS1, CRGB::Red);
          FastLED.show();
          DIY1 = false; //reset the flag for next time
          break;
        }
      case 0xFF9A65:
        if (DIY1 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Green");
          fill_solid( leds1, NUM_LEDS1, CRGB::Green);
          FastLED.show();
          DIY1 = false; //reset the flag for next time
          break;
        }
      case 0xFFA25D:
        if (DIY1 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Blue");
          fill_solid( leds1, NUM_LEDS1, CRGB::Blue);
          FastLED.show();
          DIY1 = false; //reset the flag for next time
          break;
        }
    }
    key_value = results.value;
    irrecv.resume();
  }
}
void strip2 () {

  if (irrecv.decode(&results)) {

    if (results.value == 0XFFFFFFFF)
      results.value = key_value;

    switch (results.value) {


      case 0xFF1AE5:
        if (DIY2 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Red");
          fill_solid( leds2, NUM_LEDS2, CRGB::Red);
          FastLED.show();
          DIY2 = false; //reset the flag for next time
          break;
        }
      case 0xFF9A65:
        if (DIY2 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Green");
          fill_solid( leds2, NUM_LEDS2, CRGB::Green);
          FastLED.show();
          DIY2 = false; //reset the flag for next time
          break;
        }
      case 0xFFA25D:
        if (DIY2 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Blue");
          fill_solid( leds2, NUM_LEDS2, CRGB::Blue);
          FastLED.show();
          DIY2 = false; //reset the flag for next time
          break;
        }
    }
    key_value = results.value;
    irrecv.resume();
  }
}
void strip3 () {

  if (irrecv.decode(&results)) {

    if (results.value == 0XFFFFFFFF)
      results.value = key_value;

    switch (results.value) {


      case 0xFF1AE5:
        if (DIY3 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Red");
          fill_solid( leds3, NUM_LEDS3, CRGB::Red);
          FastLED.show();
          DIY3 = false; //reset the flag for next time
          break;
        }
      case 0xFF9A65:
        if (DIY3 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Green");
          fill_solid( leds3, NUM_LEDS3, CRGB::Green);
          FastLED.show();
          DIY3 = false; //reset the flag for next time
          break;
        }
      case 0xFFA25D:
        if (DIY3 == false) //as before we started with this shift stuff
        {
          Serial.println("Select a strip first!");
        }
        else // and here shift must be true cos it can only be false or true
        {
          Serial.println("Blue");
          fill_solid( leds3, NUM_LEDS3, CRGB::Blue);
          FastLED.show();
          DIY3 = false; //reset the flag for next time
          break;
        }
    }
    key_value = results.value;
    irrecv.resume();
  }
}

Thanks,

Tom

My guess about the slowness is that because your code is over-complicated, badly structured and repetitive, irrecv.decode() and irrecv.resume() each get called, 4 times over, each time loop() is executed. My recommendation would be to reduce this to one call of each, and use arrays to remove the repetition.

In terms of using arrays: If you find yourself naming variables or symbols with a number at the end of the name, you could be using an array.

Thinking about your 3 boolean variables which record which "DIY" button was last pressed, why use 3 bools? Only one is allowed to be true at any instant, isn't it? If so, better to use a single integer variable who's value is set to 0, 1 or 2, or perhaps -1 if no button has been pressed. That way, the integer variable can be used as an index into an array, helping to remove repeated code.

Or was your idea to allow multiple DIY buttons to be pressed, followed by a colour button, and have all selected strips change together?