kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.6k stars 347 forks source link

Multiple instances #340

Closed pheuts closed 11 months ago

pheuts commented 1 year ago

Is it possible to run multiple instances so i can drive multiple ws2812 strips on multiple pin's?

moose4lord commented 1 year ago

Yes, you can. You just need to create multiple ws2812fx objects, and do the normal programming for each one. Something like this:

#include <WS2812FX.h>

#define LED_PIN      2
#define LED_PIN2     3

#define LED_COUNT   10
#define LED_COUNT2  20

WS2812FX ws2812fx  = WS2812FX(LED_COUNT,  LED_PIN,  NEO_GRB + NEO_KHZ800);
WS2812FX ws2812fx2 = WS2812FX(LED_COUNT2, LED_PIN2, NEO_GRB + NEO_KHZ800);

void setup() {
  ws2812fx.init();
  ws2812fx.setBrightness(16);
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_COMET, RED, 1000);
  ws2812fx.start();

  ws2812fx2.init();
  ws2812fx2.setBrightness(32);
  ws2812fx2.setSegment(0, 0, LED_COUNT2 - 1, FX_MODE_BLINK, BLUE, 1000);
  ws2812fx2.start();
}

void loop() {
  ws2812fx.service();
  ws2812fx2.service();
}
pheuts commented 1 year ago

Thanks for the quick response. I'll have a crack at it.

moose4lord commented 11 months ago

Stale issue, so closing.