1

The power supply is external. I want to clear one strip say pin 7, and meanwhile i dont want other strip say pin 6 to switch off...I use FastLED.clear(); FastLED.show(); But it clears all the led strips connected to pin6 and pin7. What is the code to switch off only one strip?

1 Answers1

1

You can use two CLEDController instances, which you can control separately, and by using the clearLedData you can clear either one or the other LED strip (depending on the CLEDController instance).

Below is the code I copied from https://forum.arduino.cc/t/xrads-fastled-fastled-clear-question/693569/8 which contains more info:

#include <FastLED.h>

#define COLOR_ORDER GRB #define LED_TYPE WS2812B

#define DATA_PIN 9 #define NUM_LEDS 26 CRGB leds[NUM_LEDS];

#define HEADLIGHTS 10 //headlight led pin #define NUM_HEADLIGHTS 2 CRGB leds2[NUM_HEADLIGHTS];

CLEDController &ledController = FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); CLEDController &headlightController = FastLED.addLeds<LED_TYPE, HEADLIGHTS, COLOR_ORDER>(leds2, NUM_HEADLIGHTS);

void setup() { ledController.setCorrection(TypicalLEDStrip); headlightController.setCorrection(TypicalLEDStrip);

ledController.clearLedData(); headlightController.clearLedData(); FastLED.show(); }

void loop() { }

Michel Keijzers
  • 13,014
  • 7
  • 41
  • 58