Neopixel buttoncycler modification help.

Need some help while I stumble through this project.
I’m very new to coding so bear with me.
The code below is the Neopixel buttoncycler sketch just modified to get me close to where I need to be.
I have been trying to do this by tackling all the complexities at ones, with poor results.
Baby steps will be the new approach.

Right now the sketch toggles through 5 modes, Mode 0 being off.
Modes (case) 1, 2, 3, 4 light up solid colors, with a chase pattern until all lit.
What I would like is to eliminate the chase pattern so that the modes colors just all light up.

The next step will be to change modes 3 and 4 so that only particular pixels light in the strip. Others are off. But first things first.

Thanks for any help.

// This is a demonstration on how to use an input device to trigger changes on your neo pixels.
// You should wire a momentary push button to connect from ground to a digital IO pin.  When you
// press the button it will change to a new pixel animation.  Note that you need to press the
// button once to start the first animation!

#include <Adafruit_NeoPixel.h>

#define BUTTON_PIN   2    // Digital IO pin connected to the button.  This will be
                          // driven with a pull-up resistor so the switch should
                          // pull the pin to ground momentarily.  On a high -> low
                          // transition the button press logic will execute.

#define PIXEL_PIN    6    // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 12

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);

  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW) {
      showType++;
      if (showType > 4)
        showType=0;
      startShow(showType);
    }
  }

  // Set the last button state to the old state.
  oldState = newState;
}

void startShow(int i) {
  switch(i){
    case 0: setPixelColor(strip.Color(0, 0, 0), 50);    // Black/off
            break;
    case 1: setPixelColor(strip.Color(0, 0, 255), 50);  // blue
            break;
    case 2: setPixelColor(strip.Color(255, 0, 0), 50);  // red
            break;
    case 3: setPixelColor(strip.Color(0, 0, 255), 50);  // Blue
            break;
    case 4: setPixelColor(strip.Color(0, 0, 255), 50);  //blue
           
 
  }
}

// Fill the dots one after the other with a color
void setPixelColor(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

OK, I have decided to take this on from another angle. I found a different sketch that I was able to modify to get me closer to what I need.
It probably dosnt look very pretty for most of you but seems to be working well. Any tips for cleaning it up would be great.
As of now, the sketch gives me 5 modes (one being off) of solid color, all lit pixels.
I just dont know how to advance from here.
The best solution is as follows:
Mode 0: Off
Mode 1: All Blue
Mode 2: All Red
Mode 3: Specific groups of LEDs in Blue (for example LEDS 10 - 20, 30 -40, 70-80, etc.…) Mode 3 and 4 will have some common sections.
Mode 4: Another specific group of Blue LEDs. (for example LEDS 10 - 20, 30 -40, 70-80, etc.…) Mode 3 and 4 will have some common sections.

If it makes things easier I can add 2 strips of NeoPixels on other pins for modes 3 and 4. Placing the pixels where I need them instead of calling out individual
pixels as described above.
Adding another button to switch those two modes is an option also. Obviously the code will need to be modified. I would need some hand holding for that. :slight_smile:
Any help/thoughts would be greatly appreciated.

Thanks…

#include <Adafruit_NeoPixel.h>
// Pattern types supported:
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE};
// Patern directions supported:
enum  direction { FORWARD, REVERSE };

class NeoPatterns : public Adafruit_NeoPixel
{
  public: 

  //Member variables:
  pattern ActivePattern; // which pattern is running
  direction Direction;     // direction to run the pattern

  unsigned long Interval;  // milliseconds between updates
  unsigned long lastUpdate; // last update of position

  uint32_t Color1, Color2;  // What colors are in use
  uint16_t TotalSteps;  // total number of steps in the pattern
  uint16_t Index;  // current step within the pattern

  void (*OnComplete)();

    // Constructor - calls base-class constructor to initialize strip
    NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type)
    :Adafruit_NeoPixel(pixels, pin, type)
    {}
    void Update()
    {
        if((millis() - lastUpdate) > Interval) // time to update
        {
            lastUpdate = millis();
            switch(ActivePattern)
            {
            //    case RAINBOW_CYCLE:
           //         RainbowCycleUpdate();
           //         break;
                case COLOR_WIPE:  //***********************this needed for modes (case) 0-4
                    ColorWipeUpdate();
                    break;
                default:
                    break;
            }
        }
    }
        // Increment the Index and reset at the end
    void Increment()
    {
        if (Direction == FORWARD)
        {
           Index++;
           if (Index >= TotalSteps)
            {
                Index = 0;
                if (OnComplete != NULL)
                {
                    OnComplete(); // call the comlpetion callback
                }
            }
        }
        else // Direction == REVERSE
        {
            --Index;
            if (Index <= 0)
            {
                Index = TotalSteps-1;
                if (OnComplete != NULL)
                {
                    OnComplete(); // call the comlpetion callback
                }
            }
        }
    }
 
    void ColorWipe(uint32_t color, uint8_t interval, direction dir = FORWARD)
    {
        ActivePattern = COLOR_WIPE;
        Interval = interval;
        TotalSteps = numPixels();
        Color1 = color;
        Index = 0;
        Direction = dir;
    }
    // Update the Color Wipe Pattern
    void ColorWipeUpdate()
    {
        setPixelColor(Index, Color1);
        show();
        Increment();
    }
 
};

#define BUTTON_PIN   2

#define PIXEL_PIN    6

#define PIXEL_COUNT 12

NeoPatterns Strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  Strip.begin();
  Strip.ColorWipe((0,0,0), 0);
  Strip.setBrightness(50);
  Serial.begin(9600);
}

void loop() {
  
  bool newState = digitalRead(BUTTON_PIN);
  if (newState == LOW && oldState == HIGH) {
    delay(20);
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW) {
      showType++;
      if (showType > 2) //******************************** set how many modes (case)
        showType=0;
      startShow(showType);
    }
  }
  oldState = newState;
  Strip.Update();
}
void startShow(int i) {
  switch(i){
    case 0: Strip.ActivePattern = COLOR_WIPE;
            Strip.Index = 0;
            Strip.Color1 = Strip.Color(0, 0, 0); //Black/off
            Strip.Interval = 0;
            Strip.Update();
            break;
    case 1: Strip.ActivePattern = COLOR_WIPE;
            Strip.Index = 0;
            Strip.Color1 = Strip.Color(0, 0, 255); //Blue
            Strip.Interval = 0;
            Strip.Update();
            break;
    case 2: Strip.ActivePattern = COLOR_WIPE;
            Strip.Index = 0;
            Strip.Color1 = Strip.Color(255, 0, 0); //Red
            Strip.Interval = 0;
            Strip.Update();
            break;
   case 3: Strip.ActivePattern = COLOR_WIPE;
            Strip.Index = 0;
            Strip.Color1 = Strip.Color(255, 129, 104); //Pale Red
            Strip.Interval = 0;
            Strip.Update();
            break;
   case 4: Strip.ActivePattern = COLOR_WIPE;
            Strip.Index = 0;
            Strip.Color1 = Strip.Color(104, 255, 104); //Turquoise
            Strip.Interval = 0;
            Strip.Update();
            break;
                                         
  }
}