Change loop with input pin? -SOLVED

Hello,

I'm controlling an LED RGB strip with an Uno. When an input goes High, I'd like to write 'black" to the LEDs (turn them off). I've got the LED bit sorted, but I can't seem to manage how to get the loop to instantly respond to the input state change. Of course, it's only checking the state at the top of the loop - is there some way to get the loop to respond as soon as the input goes high? Many thanks for your time, here's the relevant code:

void loop() 
  {
    
    if (digitalRead(LORCue1Pin)==LOW)
    {  
        Serial.print("Enable received from LOR, beginning sequence");
        Serial.println("");
        delay(1000);
        dither(strip.Color(0,32,0), 200);           // green, slow - to make brighter, increase each rgb param by x2
        dither(strip.Color(15,0,32), 200);          // violet, slow 
        dither(strip.Color(15,0,0), 200);           // red, slow 
        dither(strip.Color(15,0,32), 200);          // violet, slow
        dither(strip.Color(0,32,0), 200);           // green, slow
        dither(strip.Color(15,0,32), 200);          // violet, slow 
        dither(strip.Color(15,0,0), 200);           // red, slow 
        dither(strip.Color(15,0,32), 200);          // violet, slow
        scanner(0,32,0, 300);                       // green, slow  
    }
    else (digitalRead(LORCue1Pin)==HIGH);                                   
      {                                                                     
        Serial.print("Enable dropped from LOR, stopping sequence");   
        Serial.println("");
        delay(1000);                                                                  
        for (int i = 0; i < 160; i++)                                     
        {                                                                
          strip.setPixelColor(i, 0,0,0);                                  
          strip.show();                                                
        }                                                               
      }  
  }

Get rid of the one-second delays?

Good call, but that just seems to affect how often the serial print executes.

The current symptom is that if the input goes HIGH while the loop is running, the loop runs until it completes and then stops. I'd like it to (somewhat) instantly exit the loop and execute another chunk of code that writes black to the LEDs.

Sorry, newbie here.

This loop?

for (int i = 0; i < 160; i++)                                     
        {                                                                
          strip.setPixelColor(i, 0,0,0);                                  
          strip.show();                                                
        }

Well put in a test.

for (int i = 0; i < 160; i++)                                     
        {                       
         if (someCondition)
            break;                                          
          strip.setPixelColor(i, 0,0,0);                                  
          strip.show();                                                
        }
for (int i = 0; i < 160; i++)                                     
        {                                                                
          strip.setPixelColor(i, 0,0,0);                                  
          strip.show();                                                
        }

This is the code that writes 'black' to the LEDs. Somehow, I'd like to get the loop that runs when the input goes LOW to stop and execute this bit of code. "Break" doesn't seem to do what I'm after. Is there a way I should have the input be evaluated more often than at the top of the loop?

Thanks, again...

I would do something like this:

#define DITHER 1
#define SCANNER 2
#define END_OF_SEQUENCE 0

struct command
{
    char type;
    char r;
    char g;
    char b;
    unsigned int duration;
};

void command_off()
{
    for (int i = 0; i < 160; i++)                                     
    {                                                                
      strip.setPixelColor(i, 0,0,0);                                  
      strip.show();                                                
    }
}

void command_dither(const command &cmd)
{
    dither(strip.Color(cmd.r, cmd.g, cmd.b), cmd.duration);
}

void command_scanner(const command &cmd)
{
    scanner(cmd.r, cmd.g, cmd.b, cmd.duration);
}

typedef void (*cmd_fn)(const command &cmd);

const cmd_fn commands[] =  {
    command_off,
    command_dither,
    command_scanner
};

const command command_sequence[] = {
    {DITHER,   0, 32,  0, 200},
    {DITHER,  15,  0, 32, 200},
    {SCANNER,  0, 32,  0, 300},
    {END_OF_SEQUENCE, 0,0,0,0}
};

static char current_cmd = 0;
static char running = 1;

void loop()
{
    if (running)
    {
        /* Execute next LED strip action (dither, scanner, etc...) */
        commands[ command_sequence[current_cmd].type ] (command_sequence[current_cmd]);
        if (command_sequence[++current_cmd].type == END_OF_SEQUENCE)
            current_cmd = 0;
	
	if (digitalRead(LORCue1Pin) == HIGH)
	{
	    command_off();
	    running = 0;
	}
    } else {
	if (digitalRead(LORCue1Pin) == LOW)
	{
	    current_cmd = 0; // Start sequence again
	    running = 1;
	}
    }
}

Thanks for the responses. I've been able to get it to work with a small compromise, and probably not as elegant as it could be. I ended up querying the input through every step of my loop - and using BREAK to exit the loop when needed. Here's a snippet:

void loop() 
  {
    while (digitalRead(LORCue1Pin)==LOW)
    {  
        Serial.print("Enable received from LOR");
        Serial.println("");
        
        Serial.print("Step 1 of 9");   
        Serial.println("");
        dither(strip.Color(0,32,0), 200);          // green, slow - to make brighter, increase each rgb param by x2          
        if (digitalRead(LORCue1Pin)==HIGH)
        {
          turnoff();
          break;
        }

The compromise being that the current step needs to finish running before it will know to stop and turn off the LEDs. Hope this makes sense.

I'm marking this as "solved" in case it can provide useful to other beginners.

Thanks, again.