An issue in the code

I have a 16x16 matrix, and I want to control each LED in the matrix, giving it RGB values and brightness to determine its illumination. I'm using matrix_16_data to input the data using an array mentioned in the code.

When I have 128 data points, it works, meaning the code functions properly in this format:
#include <Adafruit_NeoPixel.h>

#define MATRIX_M1_PIN 7 // Matrix 16*16

Adafruit_NeoPixel matrix_16 = Adafruit_NeoPixel(256, MATRIX_M1_PIN, NEO_GRB + NEO_KHZ800);
uint8_t brightness = 0;
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;

void setup() {
matrix_16.begin();
matrix_16.show();
}

void loop() {
uint8_t matrix_16_data[][4] = {
{255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5},
{0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10},
{255, 255, 255,'-'}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {255, 255, 255,'-'}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {255, 255, 255,'-'},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50}
};

for (int i = 0; i < 128; i++) {
int row = i / 16; // Calculate the row (0-15)
int col;

if (row % 2 == 0) {
  col = i % 16; // Even rows
} else {
  col = 15 - (i % 16); // Odd rows
}

int matrixIndex = row * 16 + col;
 red = matrix_16_data[i][0];
 green = matrix_16_data[i][1];
 blue = matrix_16_data[i][2];
 brightness = matrix_16_data[i][3];


if (brightness == '-') {
  brightness = 10;
  red = 0;
  green = 0;
  blue = 0;
}
if (row % 2 == 0) {
  matrix_16.setPixelColor((row) * 16 + (15-col), brightness * red / 255, brightness * green / 255, brightness * blue / 255);
} else {
  matrix_16.setPixelColor((row) * 16 +(15-col), brightness * red / 255, brightness * green / 255, brightness * blue / 255);
}

// delay(100);

}
matrix_16.show();
}

But it doesn't work in this format:
#include <Adafruit_NeoPixel.h>

#define MATRIX_M1_PIN 7 // Matrix 16*16

Adafruit_NeoPixel matrix_16 = Adafruit_NeoPixel(256, MATRIX_M1_PIN, NEO_GRB + NEO_KHZ800);
uint8_t brightness = 0;
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;

void setup() {
matrix_16.begin();
matrix_16.show();
}

void loop() {
uint8_t matrix_16_data[][4] = {
{255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5},
{0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10},
{255, 255, 255,'-'}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {255, 255, 255,'-'}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {255, 255, 255,'-'},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5}, {255, 255, 0,5},
{0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10}, {0, 176, 240,10},
{255, 255, 255,'-'}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {255, 255, 255,'-'}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {112, 48, 160,3}, {255, 255, 255,'-'},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50},
{255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 255,'-'}, {255, 255, 0,50}
};

for (int i = 0; i < 256; i++) {
int row = i / 16; // Calculate the row (0-15)
int col;

if (row % 2 == 0) {
  col = i % 16; // Even rows
} else {
  col = 15 - (i % 16); // Odd rows
}

int matrixIndex = row * 16 + col;
 red = matrix_16_data[i][0];
 green = matrix_16_data[i][1];
 blue = matrix_16_data[i][2];
 brightness = matrix_16_data[i][3];


if (brightness == '-') {
  brightness = 10;
  red = 0;
  green = 0;
  blue = 0;
}
if (row % 2 == 0) {
  matrix_16.setPixelColor((row) * 16 + (15-col), brightness * red / 255, brightness * green / 255, brightness * blue / 255);
} else {
  matrix_16.setPixelColor((row) * 16 +(15-col), brightness * red / 255, brightness * green / 255, brightness * blue / 255);
}

// delay(100);

}
matrix_16.show();
}

I want it to work like in the second example, and I can't find the mistake. When I have a '-', it should refer to an LED that needs to be turned off.

I'm having trouble understanding the logic behind this. I would appreciate some assistance!

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

Neopixels are addressable, from "0" to "n" number of pixels (with limits), so there is no matrix to calculate or modulus to check, just count the pixels and assign color values. The pixel strip can be managed with a one dimension array (using FastLED.h for coloring):

  for (int i = 0; i < nPixels; i++) {
     leds[i] = CRGB(rgbFile[i*3+0], rgbFile[i*3+1], rgbFile[i*3+2]); // "3" is to skip every three values, +x is the color value
  }

Why isn't this working?
There are no errors, but nothing is displayed on the matrix.
////////////

#include <FastLED.h>

#define MATRIX_SIZE 16
#define NUM_LEDS (MATRIX_SIZE * MATRIX_SIZE)
#define MATRIX_PIN 7

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<WS2812B, MATRIX_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(50);  // Adjust the brightness value as needed
  FastLED.clear();
  FastLED.show();
}

void loop() {
  uint8_t matrix_16_data[][4] = {
  {255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},
{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},
{255, 255, 255,'-'},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{255, 255, 255,'-'},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{255, 255, 255,'-'},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
     {255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},

    
  
    };

  for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB(matrix_16_data[i][0], matrix_16_data[i][1], matrix_16_data[i][2]);
  }

  FastLED.show();
  delay(100);
}

Each subscript of the array has four elements.

You are only using three of the four.

Try a simple sketch. Count from 0 to 32 (only two rows of neopixels). Give each count a known color (0, 0, 255). Do you see two rows of blue neopixels? If yes, do the same and add a noticeable brightness step (brightness += 5). Do you see two rows of blue neopixels increasing in brightness?

p.s. Move your matrix outside of the void loop() function. You are re-declaring it each iteration.

p.p.s. You need to name a signal pin.

I see something going wrong after the third set of 16 neopixels...


First of all, thank you very much for the help!
I have the same issue, it works until line 10, and if I add more lines, nothing happens.

#include <FastLED.h>

#define MATRIX_SIZE 16
#define NUM_LEDS (MATRIX_SIZE * MATRIX_SIZE)
#define MATRIX_PIN 7

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<WS2812B, MATRIX_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(50);  // Adjust the brightness value as needed
  FastLED.clear();
  FastLED.show();
}

void loop() {
  uint8_t matrix_16_data[][3] = {
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},

  };

  for (int i = 0; i < 16*10; i++) {
    // leds[i] = CRGB(matrix_16_data[1][0], matrix_16_data[1][1], matrix_16_data[1][2]);
    leds[i] = CRGB(matrix_16_data[i][0], matrix_16_data[i][1], matrix_16_data[i][2]);
  }

  FastLED.show();
  delay(100);
}

Do you mean the tenth line of 16 neopixels? Also, describe what does not work... black? white? wrong color?

when i put 16 on 16 ,and add 16 lines to matrix_16_data it didnt show anything
but for 16*10 lines it do

This example doesn't work

#include <FastLED.h>

#define MATRIX_SIZE 16
#define NUM_LEDS (MATRIX_SIZE * MATRIX_SIZE)
#define MATRIX_PIN 7

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<WS2812B, MATRIX_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(50);  // Adjust the brightness value as needed
  FastLED.clear();
  FastLED.show();
}

void loop() {
  uint8_t matrix_16_data[][3] = {
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0},
  {200, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},  {0, 40, 0},{0, 40, 0},{0, 40, 0},{0,40,0}
  };

  for (int i = 0; i < 16*16; i++) {
    // leds[i] = CRGB(matrix_16_data[1][0], matrix_16_data[1][1], matrix_16_data[1][2]);
    leds[i] = CRGB(matrix_16_data[i][0], matrix_16_data[i][1], matrix_16_data[i][2]);
  }

  FastLED.show();
  delay(100);
}```

I see that everything works... this is your code in a 16x16... FROM POST #7

I have a matrix of LEDs with 16 rows and 16 columns.

So does the simulator. Sixteen rings of sixteen pixels.

Something in your code of post #9 broke your working code... I get no color in any pixel.

I can't understand where the issue is. I've prepared 256 colors for each LED.
The colors are also not correct.

Take the matrix out of loop and put it by itself and your code will work.
Your code had one red pixel per 16 columns...

I made the color change.

Here is your code in a simulation:

Thank you very much, it really worked!
I'm trying to assign data to each matrix separately, and I'm encountering this problem:
Not enough memory;data section exceeds available space in board

Compilation error: data section exceeds available space in board

and can't solve it. What should I do? I have many more data tables to input.

#include <FastLED.h>

#define MATRIX_SIZE 16
#define NUM_LEDS (MATRIX_SIZE * MATRIX_SIZE)
#define MATRIX_PIN 7
#define BRIGHTNESS 255
CRGB leds[NUM_LEDS];

#define BIG_RING_SIZE 32
#define RING_PIN 4
CRGB big_ring_leds[NUM_LEDS];


uint8_t matrix_16_data[][4] = {
   {255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},
{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},
{255, 255, 255,'-'},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{255, 255, 255,'-'},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{112, 48, 160,3},	{255, 255, 255,'-'},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50},
{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 255,'-'},	{255, 255, 0,50}
};

uint8_t big_ring_data[][4] = {
   {255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},	{255, 255, 0,5},
{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10},	{0, 176, 240,10}
};

void setup() {
  FastLED.addLeds<WS2812B, MATRIX_PIN, GRB>(leds, NUM_LEDS);
    FastLED.addLeds<WS2812B, RING_PIN, GRB>(big_ring_leds, BIG_RING_SIZE);

  FastLED.setBrightness(BRIGHTNESS); // Adjust the brightness value as needed
  FastLED.clear();
  FastLED.show();
}

void loop() {
  shir11();
  shir12();
}

void shir11() {
  for (int i = 0; i < NUM_LEDS; i++) {
    // leds[i] = CRGB(matrix_16_data[i][0], matrix_16_data[i][1], matrix_16_data[i][2]);
    leds[i] = CRGB(matrix_16_data[i][0], matrix_16_data[i][1], matrix_16_data[i][2]).scale8(matrix_16_data[i][3]);
  }
  FastLED.show();
  delay(100);
}

void shir12() {
  for (int i = 0; i < 32; i++) {
    // leds[i] = CRGB(matrix_16_data[i][0], matrix_16_data[i][1], matrix_16_data[i][2]);
    big_ring_leds[i] = CRGB(big_ring_data[i][0], big_ring_data[i][1], big_ring_data[i][2]).scale8(big_ring_data[i][3]);
  }
  FastLED.show();
  delay(100);
}```

I had this same issue when I tried to expand this matrix by sixteen^2 (48x48). Somewhere in FastLED or Adafruit_Neopixel explains the memory requirement per pixel and gives a theoretical limit due to memory. Some Arduino boards have more memory (I do not know which). That would be my only solution for bigger matrices (BIG_RING_SIZE 32)...

[edit]
I now see you are reserving memory with the object "leds" as well as the object "big_ring_leds"... but only using one in your code... I would choose to use (reserve memory with) only one of those objects and write code to address the desired neopixels.

I like that you are using function calls to make new functions without breaking the old code.

leds[i] = CRGB(random(255), random(255), random(255));

@shir111 - I put together a 16x16 matrix. I bungled the order (0 to 15, bottom to top).

I have 9 matrices that I want to light up together, and for each one, I want to load its respective array. How can I deal with memory issues in such a case? I don't want it to be random.

Would you post a hand drawn picture? (only of the squares of the matrices, not the schematic)

Nine 16x16... I can't do the math but... you might have to use a few Arduinos.

More parts are missing, but this is a section. Is it impossible for everything to be connected to a single Arduino? I want everything to be synchronized from one to the other.

Just following along from under the umbrella, is there a reason you didn't just use one matrix of 16 rows and 16 columns?

a7