Arduino Uno R3 can't handle more than 4 rows for Neomatrix

I am a beginner at using an Arduino and coding in general.

I have a project to program a display that uses neopixels set up in 10 rows and 60 columns. To make the display show what I wanted I used the neomatrix library and it worked for what I need.

However, I noticed that for some reason I cannot actually send the data for all 10 rows. The maximum I can do is 4 rows with my current program. To tackle the issue right now what I do is initialize a neomatrix (named display in the code below) of 4 rows and 60 columns, and simply rotate between 3 different pins (4 rows, 4 rows, 2 rows) to send the data. The issue here is that I must show the pixels before moving on to the next pin, which means that the first 4 rows update, then the next 4 rows update and so on. This is VERY noticeable (also because my code is slow), but I simply don't understand why I can't send data to more rows at once when I see many people online sending data to way more neopixels than I am.

I am quite sure it's not a powering issue, because testing has shown me that there simply isn't a signal going through instead of the neopixels needing more power.
What I mean is: I show text on the display with 4 rows, then I changed the sketch to send different text for 10 rows. The 4 rows are still on in the same fashion due to no new signal being sent through indicating they were not updated.
I tested further a 10-row declaration on only 2 physically connected rows, and the signal didn't send through. This has confused me very much.
I also noticed that the less memory I use, the more rows I can send data to. Smaller sketches have allowed me to send data for 6 rows.

Is there a way to solve this issue? I would greatly appreciate any guidance.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <FiveByThreePixelFont.h>
//#include <Fonts/Picopixel.h>

#define DISPLAY_TOP_PIN 8
#define DISPLAY_MID_PIN 7
#define DISPLAY_BOT_PIN 6

#define STRIP_PIN 8
#define SMALL_ROWS 2
#define ROWS 4
#define COLS 60
#define STRIP_LENGTH ROWS*COLS

#define BRIGHTNESS 50

#define CYBER_BLUE display.Color(0,184,255)
#define CYBER_PINK display.Color(214,0,255)
#define CYBER_YELLOW display.Color(253,255,110)
#define BLANK display.Color(0,0,0)


Adafruit_NeoMatrix display = Adafruit_NeoMatrix(

  COLS, ROWS, DISPLAY_TOP_PIN,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
  NEO_GRB + NEO_KHZ800

  );


Adafruit_NeoPixel strip(STRIP_LENGTH, STRIP_PIN, NEO_GRB + NEO_KHZ800);


int highlight;
int default_color;

int max_x;
int x_location;
int y_location;

int universal_current_line = 0;
int scroll_draw_x = 0;
int row_limit = ROWS;
int line_length = 0;

void setup() {
  Serial.begin(9600);

  strip.begin();
  strip.show();

  strip.fill(strip.Color(255, 255, 0), 0, STRIP_LENGTH);
  strip.show();


  default_color = CYBER_BLUE;


  display.begin();
  display.setTextWrap(false);
  display.setBrightness(BRIGHTNESS);
  display.setTextColor(default_color);
  display.setFont(&FiveByThreePixelFont);
  display.setPin(DISPLAY_TOP_PIN);

  highlight = 0;

  x_location = 0;
  y_location = 5;
  String raw_text = " HELLO WORLD? BYE WORLD!!!";
  int width = 4; //when changing fonts this changes as well, make it a global variable later
  max_x = -(raw_text.length() + 2) * width;
}

void InitialMatrixTest() {

  ScrollText();
  int x = display.getCursorX();
  int y = display.getCursorY();

  //Add a single space padding to all incoming text
  display.setPin(DISPLAY_TOP_PIN);
  display.fillScreen(display.Color(0,0,0));
  display.print(" HELLO ");
  Highlight("WORLD");
  display.print("?");
  display.show();

  display.setPin(DISPLAY_MID_PIN);
  display.setCursor(x, y);
  display.fillScreen(display.Color(0,0,0));
  display.print(" BYE ");
  Highlight("WORLD");
  display.print("!!!");
  display.show();



  delay(10);
}

void ScrollText() {
  x_location--;

  if (x_location == max_x){
    x_location = COLS;
  }

  display.setCursor(x_location, y_location);
}

void Highlight(String text) {
  if (highlight == 1) {
    display.setTextColor(CYBER_YELLOW);
    highlight = 0;
  } else {
    display.setTextColor(CYBER_PINK);
    highlight = 1;
  }

  display.print(text);
  display.setTextColor(default_color);


}



void LoopMatrix() {
  //UniversalMatrixPrint();
  InitialMatrixTest();
}

void loop() {
  LoopMatrix();
}


I was able to get about 600 Neopixels into Arduino Uno/Nano memory... that is 10x60... using FastLED.h. Give that a try?

The memory problem you might be having is due to the Font library. Those take up a lot of space.

Thanks for the fast response, I will try this!

If you want scrolling text, take a look at this simulation. It is only 32x8 (256 total). Maybe you can size it to your liking...

I also notice your use of "String" (upper-case S). From what I read, String has poor memory management (allocates memory but never returns it). That could also be causing your "max four rows" issue

Hi thanks for simulator. I altered the code to fit and tested this code on my display and unfortunately it doesn't work again. If String is slow, what can I use as a replacement?

I understand and agree the issue is the font library. It is my own custom font only holding basic punctuation and capital letters in a 5 by 3 matrix of pixels. This is perhaps the smallest library I could make for text. Would using an SD help for this issue?

String is not slow, it uses memory and forgets how to return memory when it is done using it.

Use arrays of characters:

char blerp[] = {"poolb\0"};
void setup() {
  Serial.begin(115200);
  Serial.println(blerp);
  Serial.print(blerp[2]);
  Serial.print(blerp[4]);
  Serial.print(blerp[1]);
  Serial.print(blerp[0]);
  Serial.print(blerp[3]);
}
void loop() {}

That would add another library (more memory used). The compiled program does not change in size when running.

You indeed can if you don't have anything "fancy". Any of the libraries (FastLed, Adafruit_Neopixel) will allocate 1800 bytes for 600 pixels, either at compile time or at run time.

I've compiled the FastLED blink example blinking the first pixel in a strip with a size of 600 pixels (allocated) and memory usage is 1901 bytes (and a warning). The FastLED Fire2012 example by far exceeds the available memory of an Uno.

@asutoronoto

The Adafruit Neopixel library allocates memory at run time so it's not counted in the memory report of the IDE; you will have to add 1800 bytes to the memory usage.

Ok so what I'm understanding is basically I need more memory and I'll be set. I'm considering getting the Uno R4 Minima as it's on a massive sale at my local store right now. From my understanding the R4 Minima has significantly more memory than the R3 AND runs faster, so it sounds to me like the solution to my problem. Do you think this is a good idea?

https://docs.arduino.cc/hardware/

1 Like

Thank you for the link. So I'm going to go ahead and buy an R4 Minima to see if it works out for me but it seems like it should given how its 3x faster and has 16x more memory. Might be a bit unnecessarily powerful for what I need but I can always use the remaining pins for other projects as this one is just going to be in a room. I will update the thread regarding the results but I'm sure this will work.

Also read about the Espressif ESP32... a lot of Neopixel projects use the ESP32 due to its memory capacity and speed. Some ESP32 have a very small footprint (coin sized).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.