LED matrix

I need help about Arduino LED matrix

it’s not working properly(the second frame doesn’t render, work only first code (led array)) can you help me,

led_matrix.ino (3.17 KB)

the second frame doesn't render

No wonder. The RenderFrame() function only uses the first array of LED data

Either write a second function to render the second array or better, change the RenderFrame() function to accept an array as a parameter and call it with the second array as a parameter

I note, however, that the code posted does not compile due to

  RenderFrame(ledarray[1]);

in setup()

You also declare you have 50 pixels and then set up your arrays to have 56 elements, but your RenderFrame() function iterates over 256 elements of your array (which don’t exist). I believe the adafruit library does bounds checking which is preventing bad things from happening when your code runs.

Try this:

// ===============================================
// LED Matrix Studio "NeoPixel" template
//
// Works with many RGB 8x32 displays
// (common to eBay)
//
// Render a single frame of colour data.
// LED Matrix Studio, new RGB, 8x32.
//
// Use the Export Code option
//
// maximumoctopus.com
// maximumoctopus.com/electronics/builder.htm
//
// based on the Adafruit Neopixel demo code
// ===============================================
// 256 <- should say 256

#include <Adafruit_NeoPixel.h>

#define PIN 2


uint32_t ledarray[] = {
                       0xFF000000, 0x0FF00000, 0x0000FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 
                       0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 
                       0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 
                       0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       };
uint32_t ledarray1[] = {
                       0xFF0000FF, 0x00FF0000, 0x00000000, 0x0FF00000, 0x00000000, 0x0000FF00, 0x00000000, 0x00000000, 
                       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 
                       0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00FF0000, 0x00000000, 0x00000000, 0xFF000000, 
                       0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 
                       0xFF000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
                       };

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

const int NUM_PIXELS = 50;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_RGB + NEO_KHZ800);

void setup()
{
  strip.begin();
  strip.setBrightness(64);
  strip.show();   // Initialize all pixels to 'off'
}

void loop()
{
  RenderFrame(ledarray);
  delay(500);
  RenderFrame(ledarray1);
  delay(500);
}

void RenderFrame(const uint32_t *arr)
{
  for (uint16_t t = 0; t < NUM_PIXELS; t++)
  {
    strip.setPixelColor(t, arr[t]);
  }
  strip.show();
}