Changing multiple Neopixel strip patterns using different buttons instantly

Hi!

First post so apologies for any formatting issues.

I’m looking to control (change patterns) multiple Neopixel LED strips using different buttons, with no delay.

The way ive found to do this (through learning off other forum users), seems to be using an array.

My question is - how do I add more than one array? so that I can replicate my code in the other strips, I haven’t been able to work out how to do this.

#include "FastLED.h"
#include <JC_Button.h>
FASTLED_USING_NAMESPACE
#define LED_TYPE    WS2811
#define NUM_LEDS_PART_A 110  //MONITOR LEDs
#define COLOR_ORDER GRB
#define BRIGHTNESS          96
#define FRAMES_PER_SECOND  120

CRGB ledsA[NUM_LEDS_PART_A]; //declaring led strips

const int TR1 = 30; // Monitor LEDs
const int TR2 = 28; // Signal LEDs and shelf leds
const int buttonPin2 = 53;     // Button 2 (Under power button)
const int pcstatus = 40; //Signal in from the PC. HIGH when pc on
int pcstate = 0;//pc status

Button Btn2(buttonPin2, true, true, 50); 

void setup() {

  Serial.begin(57600); // leds
  delay(1000); // 3 second delay for recovery

 FastLED.addLeds<NEOPIXEL, 2>(ledsA, NUM_LEDS_PART_A);

  pinMode(TR1, OUTPUT); // Behind panel transitor, turns on when microswitch1 open
  pinMode(TR2, OUTPUT); // PC on transistor, turns on when PC on, allows power to LED strips etc
  pinMode(pcstatus, INPUT); // initializes pc in signal as an input
    }
typedef int (*SimplePatternList[])();
SimplePatternList gPatterns = {monitorrainbow, monitorjuggle };
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns


void loop()

{
gPatterns[gCurrentPatternNumber]();
FastLED.show();  
FastLED.delay(1000/FRAMES_PER_SECOND); 
readbutton2();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
pcstate = digitalRead(pcstatus);
pconoff();
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void pconoff ()

{

 if (pcstate = HIGH) {
    digitalWrite(TR1, HIGH);
    digitalWrite(TR2, HIGH);
  } else {
    digitalWrite(TR1, LOW);
    digitalWrite(TR2, LOW);
  }
  
}

void nextPattern2()

{
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void monitorrainbow() 

{
  fill_rainbow( ledsA, NUM_LEDS_PART_A, gHue, 7);
}

void monitorjuggle() {

  fadeToBlackBy( ledsA, NUM_LEDS_PART_A, 20);
  byte dothue = 0;
  for( int i = 0; i < 8; i++) {
    ledsA[beatsin16(i+7,0,NUM_LEDS_PART_A-1)] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}

void readbutton2() {                                       

  Btn2.read();
  if(Btn2.wasReleased()) {
  nextPattern2();

  }
}

The way ive found to do this (through learning off other forum users), seems to be using an array.

No.

The way you do it is with a state machine like the blink without delay example in the IDE. You need to remove all delays and unroll all loops with a delay in them. Posted this many times here. I am on my iPad so I can’t post it again just yet.

Ok... I've been playing around with that example for a while and I feeling like i'm hitting a wall. How do I create a program similar to the one below using millis() and similar, I can't get my head around how to use it for my purpose?

Would you be able to link me to that code you mentioned so I haven't got to bombard you with questions and hopefully I can come back with educated ones?

Reply #4 https://forum.arduino.cc/index.php?topic=412232.0