Hello!
i have multiple controller, five ledstrip connected to five outputs of Arduino, and all strips are one array - leds. The question is how to turn off one strip, for example when a button pressed? Other strips must work. I dont want to split up the array. Maybe there is a solution, such as assign output Arduino as an input?
I’m definitely not an authority, but I think that changing the pin state will only kill the stream of data to the strip on the pin you are manipulating. (I imagine doing a digitalWrite(DATA_PINx, LOW) is electronically safe). But the problem is that you’ll need to assign the LEDs on that particular strip all black to make them appear off.
So, if I understand you correctly all 5 strips are displaying the same thing?.
Why not break up the strips to leds, leds1, leds2…?
then you can watch the buttons and control each separately. They can all still display the same data if you want but then at least you have control over individual strips per pin and can assign the leds on the strip to black upon button press.
If your code is similar to the MirroringSample you just need to do a few little changes and define the separate strips… i.e. leds, leds1, leds2… and then I suppose duplicate the call to the pointer to the leds…
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
// set our current dot to red
leds[i] = CRGB::Red;
leds1[i] = CRGB::Red;
leds2[i] = CRGB::Red;
leds3[i] = CRGB::Red;
FastLED.show();
…
But I’m sure that can be optimized as well…
Any time the lights change, you have to tell all the lights in a controller what to change to. They are shift registers and the chips in the leds store the information. Only way to turn them off is to send them zeros or turn the power off. You could power the whole strip down with a mosfet at the cost of an additional pin but would have to synchronize a refresh with turning it back on to get the data reloaded.
Many thanks for your answers, i make a multilevel ceiling lighting. Controller which controls the strips will be hidden in the ceiling. It is controlled by radio Nrf+. Another controller (touch panel) is set in a different place, sends commands to the switch light, manages five zones, and changing effects.
I moved the setting (assignment) exits from “void setup” to function “checking”.
Written in a loop checking the array of received data.
If there are changes, the appeal to change the output function.
below this ugly code:
for (int c=0; c<5; c++)
{
if(pd[c]!=bufff[c+1]) /////// bufff - received data, pd - storage array previous values
{
fill_solid( leds, NUM_LEDS, CRGB::Black);
FastLED.show();
checking©; //// change output settings function
}
pd[c]=bufff[c+1];
}
…
void checking (int c)
{
switch ©
{
case 0:
if (bufff[c+1]) FastLED.addLeds<LED_TYPE, 4, COLOR_ORDER>(leds, 0, NUM_LEDS_PER_STRIP);
else pinMode(4, INPUT);
break;
case 1:
if (bufff[c+1]) FastLED.addLeds<LED_TYPE, 5, COLOR_ORDER>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
else pinMode(5, INPUT);
break;
case 2:
if (bufff[c+1]) FastLED.addLeds<LED_TYPE, 6, COLOR_ORDER>(leds, 2 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
else pinMode(6, INPUT);
break;
case 3:
if (bufff[c+1]) FastLED.addLeds<LED_TYPE, 7, COLOR_ORDER>(leds, 3 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
else pinMode(7, INPUT);
break;
case 4:
if (bufff[c+1]) FastLED.addLeds<LED_TYPE, 8, COLOR_ORDER>(leds, 4 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
else pinMode(8, INPUT);
break;
}
}
Its working very well, but I doubt that this is correct…
What is the purpose of the checking procedure? Not sure what this code is doing. Are the lights ever on? when you addleds you are initializing the strip of leds, that should likely stay in the setup procedure. The fill_solid should take care of turning off the leds. What you are missing in this code is turning the LEDs on.