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 / portTICKPERIOD_MS);
} } ~~~ Thanks for your replies!