Neopixels and Mcp23017 hubs

Hi there, I've got 7 strips of neopixel leds connected to the Arduino. Ive got 5 MCP23017 hubs with 16 buttons connected to the Arduino via i2c. Ive got it working through an array, that each button switches on a specific LED.

However I've got an individual button connected directly to the Arduino. Its function is to turn on all the LEDS on all the strings. Again that with a simple piece of debounce code this works fine, but it stops the code for the individual buttons working i.e. the indiviual leds will flicker on for a fraction of a second and then go out.

I realise that that is because the "ALL LEDS ON" button, determines a continuously looping state, on or off ("if" or "else") for the LEDS.

How can I do the "BUTTON TO TURN ALL LEDS ON ALL LEDS ON" button so it's not continously looping and causing this conflict i.e stopping the individual lights coming on when requested?

valhs = digitalRead(PINHS);
if ((valhs == HIGH) && (old_valhs == LOW)){
  state_hs = 1 - state_hs;
old_valhs = valhs;
if (state_hs == 1) {
strip0.setPixelColor(0,strip0.Color(175, 50, 0));
strip0.setPixelColor(1,strip0.Color(175, 50, 0));
strip0.setPixelColor(2,strip0.Color(175, 50, 0));
strip0.setPixelColor(3,strip0.Color(175, 50, 0));
strip0.setPixelColor(4,strip0.Color(175, 50, 0));
strip0.setPixelColor(5,strip0.Color(175, 50, 0));
strip0.setPixelColor(6,strip0.Color(175, 50, 0));
strip0.setPixelColor(7,strip0.Color(175, 50, 0));
strip0.setPixelColor(8,strip0.Color(175, 50, 0));
strip0.setPixelColor(9,strip0.Color(175, 50, 0));
strip0.setPixelColor(10,strip0.Color(0, 175, 50));
strip0.setPixelColor(11,strip0.Color(175, 50, 0));
} else {
strip0.setPixelColor(0,strip0.Color(0, 0, 0));
strip0.setPixelColor(1,strip0.Color(0, 0, 0));
strip0.setPixelColor(2,strip0.Color(0, 0, 0));
strip0.setPixelColor(3,strip0.Color(0, 0, 0));
strip0.setPixelColor(4,strip0.Color(0, 0, 0));
strip0.setPixelColor(5,strip0.Color(0, 0, 0));
strip0.setPixelColor(6,strip0.Color(0, 0, 0));
strip0.setPixelColor(7,strip0.Color(0, 0, 0));
strip0.setPixelColor(8,strip0.Color(0, 0, 0));
strip0.setPixelColor(9,strip0.Color(0, 0, 0));
strip0.setPixelColor(10,strip0.Color(0, 0, 0));
strip0.setPixelColor(11,strip0.Color(0, 0, 0));;

Any help would be gratefully accepted, I've run out of ideas

Any help would be gratefully accepted, I've run out of ideas

And also run out of code it seems. Please post all your code so it can be seen in context.

Hi Grumpy Mike,
Thanks for responding. There is ALOT of code, arrays and would take ALOT of explanation. Can totally understand the need to see the bigger picture but there’s also a patent consideration. Is there a simple way to stop the leds state being controlled primarily by the state of the this button?
If I remove this code all the other buttons and leds work fine. When I put it in the just briefly flicker.

Again, any help would be appreciated been at it all day with no success.

Is there a simple way to stop the leds state being controlled primarily by the state of the this button?

Yes, that should not happen so you are doing something wrong.

There is ALOT of code,

So you write something small that shows your problem. Often doing this makes you spot the problem. If not then maybe we can.