How to Control LED matrixes

I’m trying to controll multiple LED matrixes WS2812B using FastLED and FreeRTOS library on arduino nano(ATmega328). In case i run multiple tasks with a special one for LED matrix, then it works well. But if i add another one (“TaskLEDRainbow2), everything goes into the hell. It successfuly uploads on the board, but istead of showing the effect the built-in LED(pin13) starts blasting as crazy and nothing works at total. What’s wrong with it? What mistake did i made? Here’s the sketch i try to upload: ~~~

include <Arduino_FreeRTOS.h>

include <FastLED.h>

define NUM_LEDS 64 // using x2 matrixes ws2812b size: 8×8

define DATAPIN1 6 // each matrix has its’ own pin

define DATAPIN2 3

CRGB leds[NUMLEDS]; CRGB leds2[NUMLEDS]; byte counter; byte counter2; void TaskBlink( void *pvParameters ); void TaskLEDRainbow( void *pvParameters ); void TaskLEDRainbow2( void *pvParameters ); void setup() { Serial.begin(9600); while (!Serial) { ; } xTaskCreate( TaskBlink , (const portCHAR *)”Blink” , 128 // Stack size , NULL , 2 // Priority , NULL );
xTaskCreate(
TaskLEDRainbow
,  (const portCHAR *) "f2"
,  512  // Stack size
,  NULL
,  1  // Priority
,  NULL );


xTaskCreate(
TaskLEDRainbow2
,  (const portCHAR *) "f3"
,  512  // Stack size
,  NULL
,  1  // Priority
,  NULL );
} void loop() { } void TaskBlink(void *pvParameters) // 1st load task just for test { (void) pvParameters; // initialize digital LEDBUILTIN on pin 13 as an output. pinMode(LEDBUILTIN, OUTPUT); for (;;) { digitalWrite(LEDBUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) vTaskDelay( 1000 / portTICKPERIODMS ); digitalWrite(LEDBUILTIN, LOW); // turn the LED off by making the voltage LOW vTaskDelay( 1000 / portTICKPERIODMS ); } } void TaskLEDRainbow(void *pvParameters) // Task for the 1st matrix { (void) pvParameters; FastLED.addLeds<WS2811, DATA_PIN_1, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness(5); pinMode(DATA_PIN_1, OUTPUT); for(;;){ for (int i = 0; i < NUM_LEDS; i++ ) {
leds[i] = CHSV(counter + i * 2, 255, 255); } counter++; // counter changes from0 to 255 (data type – bytes) FastLED.show(); vTaskDelay(1000 / portTICK_PERIOD_MS); // speed of the effect } } void TaskLEDRainbow2(void *pvParameters) // Same as the “TaskLEDRainbow()” { (void) pvParameters; FastLED.addLeds<WS2811, DATA_PIN_2, GRB>(leds2, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness(5); pinMode(DATA_PIN_2, OUTPUT); for(;;){ for (int i = 0; i < NUMLEDS; i++ ) {
leds2[i] = CHSV(counter + i * 2, 255, 255); } counter2++;
FastLED.show(); vTaskDelay(5000 / portTICK
PERIOD_MS);
} } ~~~ Thanks for your replies!

How to Control LED matrixes

One big question is ‘FastLED’ thread safe, and is it designed to be able to handle two different sets of leds at once. This is really a question for some forum that knows that library.