Go Down

Topic: Neopixels and Mcp23017 hubs (Read 154 times) previous topic - next topic

Cathalbr

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?
Code: [Select]
//BUTTON TO TURN ALL LEDS ON
valhs = digitalRead(PINHS);
if ((valhs == HIGH) && (old_valhs == LOW)){
  state_hs = 1 - state_hs;
  delay(10);
}
old_valhs = valhs;
if (state_hs == 1) {
  housestatusB();
   digitalWrite(13,HIGH);
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 {
digitalWrite(13,LOW);
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));
   strip0.show();
}


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

Grumpy_Mike

Quote
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.

Cathalbr

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. 

Grumpy_Mike

Quote
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.

Quote
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.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy