Width of matrix

Hi,
i have a code and I have width of matrix 32 px, height of matrix is 8
I would like to help me to make the width matrix is 64.
When I change the matrix width number to 64, the code doesn't work
its only works at number 52
Thanks advance

What matrix? Are you referring to an LED matrix. Post the datasheet (s).

Is there a library for the matrix?

Which Arduino are you using?

i will send you the code right now

#include <SoftwareSerial.h>
#include "Arduino.h"
#include <Wire.h>//Include libraries: SoftwareSerial & Wire
SoftwareSerial ESP_BT(0, 1); //Define PIN11 & PIN12 as RX and TX pins

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>

#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 5

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = 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_GRBW Pixels are wired for GRBW bitstream (RGB+W NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// Example for NeoPixel Shield. In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino. When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order. The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(
32, //Select LEDs of each row (15 in my case)
8, //Select amount of rows (7 in my case)
PIN,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + //Define first data pin (right bottom corner is my first pin)
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG, //Define the type of connection (in a zig zag connections and divided by rows not columns)
NEO_RGB + NEO_KHZ800);

int Red = 255, Green = 0, Blue = 0;
String text = "Easy Tech";
String RGB;
int pixelPerChar = 5, RGB_Completed = 0;
int Delay, Brightness;
const uint16_t colors[] = {matrix.Color(Green, Red, Blue)};

// matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };//matrix.Color(Red, Green, Blue),

void initdata() {

int Speed = EEPROM.read(0);
if (Speed == NULL || Speed == 0) {
Delay = 100;
}
else {
Delay = Speed;
}

int bright = EEPROM.read(5);
if (bright == NULL || bright == 0) {
Brightness = 40;
}
else {
Brightness = bright;
}

int r = EEPROM.read(10);
if (r == NULL) {
Red = 0;
}
else {
Red = r;
}

int g = EEPROM.read(15);
if (g == NULL) {
Green = 255;
}
else {
Green = g;
}

int b = EEPROM.read(20);
if (b == NULL) {
Blue = 0;
}
else {
Blue = b;
}
char data[100]; //Max 100 Bytes
int len = 0;
char k;
String Text = "";
k = EEPROM.read(50);
while (k != '\0' && len < 500) //Read until null character
{
k = EEPROM.read(50 + len);
data[len] = k;
Text += k;
len++;
}
data[len] = '\0';

if (Text == NULL) {
text = "EASY TECH";
}
else {
text = Text;
}
Serial.println(Speed);
Serial.println(Brightness);
Serial.println(Red);
Serial.println(Green);
Serial.println(Blue);
Serial.println(text);

}

void setup() {

Serial.begin(115200);
ESP_BT.begin(9600);
EEPROM.begin();
initdata();
// Serial.println("Start");
const uint16_t colors[] = {matrix.Color(Green, Red, Blue)};
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(Brightness);
matrix.setTextColor(colors[0]);
//matrix.setTextColor(matrix.Color(Green,Red,Blue));
}

int x = matrix.width();
int pass = 0;

void loop() {

while (ESP_BT.available()) {
char ReadChar = (char)ESP_BT.read();
Serial.println(ReadChar);

// Right parentheses ) indicates complet of the string
if (ReadChar == ')' || ReadChar == '}' || ReadChar == ']') {
  if (ReadChar == ')' ) {
    RGB_Completed = 1;
  }
  
  if (ReadChar == '}') {
    RGB_Completed = 2;
  }
  
  if (ReadChar == ']') {
    RGB_Completed = 3;
  }
}

else {
  RGB += ReadChar;
}

}

if (RGB_Completed != 0) {
if (RGB_Completed == 1) {
Light_RGB_LED();
RGB_Completed = 0;
}

if (RGB_Completed == 2) {
  text = RGB;
  int _size = text.length();
  int i;
  
  for (i = 0; i < _size; i++) {
    EEPROM.write(50 + i, text.charAt(i));
    Serial.println(text.charAt(i));
  }
  
  EEPROM.write(50 + _size, '\0'); //Add termination null character for String Data

  RGB_Completed = 0;
  RGB = "";
}

if (RGB_Completed == 3) {
  int val = RGB.toInt();
  if (val > 0 && val <= 100) {
    if (val == 0) {
      val = 1;
    }
    Delay = (100 - val) * 2.5;
    //scroll(Delay);
    EEPROM.write(0, Delay);
  }
  else {
    val = val - 100;
    matrix.setBrightness(val);
    EEPROM.write(5, val);
  }

  RGB = "";
  RGB_Completed = 0;
}

}

if (RGB_Completed == 0) {
//. Serial.println(RGB_Completed);
scroll();
}
}

void scroll() {
//Serial.println(text);
int maxDisplacement = text.length() * pixelPerChar + matrix.width();
matrix.fillScreen(0);
matrix.setCursor(x, 0);

matrix.print(text);
if (--x < -maxDisplacement) {
x = matrix.width();

if (++pass >= 1) {
  pass = 0;
  // matrix.setTextColor(colors[pass]);
  matrix.setTextColor(matrix.Color(Green, Red, Blue));
  //  matrix.setTextColor(matrix.Color(Red,Green,Blue));
}

}

matrix.show();
delay(Delay);
}

void Light_RGB_LED() {

int SP1 = RGB.indexOf('.');
int SP2 = RGB.indexOf('.', SP1 + 1);
int SP3 = RGB.indexOf('.', SP2 + 1);
String R = RGB.substring(0, SP1);
String G = RGB.substring(SP1 + 1, SP2);
String B = RGB.substring(SP2 + 1, SP3);
Red = R.toInt(); Green = G.toInt(); Blue = B.toInt();
// Serial.println(R);
matrix.setTextColor(matrix.Color(Green, Red, Blue));
EEPROM.write(10, Red); EEPROM.write(15, Green); EEPROM.write(20, Blue);
RGB = "";

}

Have you simply run out of memory?

It helps us to help you if you answer the questions you've been asked.
And use code tags.

1 Like

What is the arduino board do you use?
Matrix 52x8 contains more than 400 pixels, it is too much if you using the Uno board

I am using Arduino UNO
Is it possible to run out of memory?

Of course it is!
You have only 2k of RAM.

Why are you using software serial on hardware serial pins?

How will I solve this problem please?

Can you change the code to what you think is best please?

Can you post your code in code tags, please?

#include <SoftwareSerial.h>
#include "Arduino.h"
#include <Wire.h>//Include libraries: SoftwareSerial & Wire
SoftwareSerial ESP_BT(0, 1); //Define PIN11 & PIN12 as RX and TX pins

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>

#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 5

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = 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_GRBW Pixels are wired for GRBW bitstream (RGB+W NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// Example for NeoPixel Shield. In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino. When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order. The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(
32, //Select LEDs of each row (15 in my case)
8, //Select amount of rows (7 in my case)
PIN,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + //Define first data pin (right bottom corner is my first pin)
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG, //Define the type of connection (in a zig zag connections and divided by rows not columns)
NEO_RGB + NEO_KHZ800);

int Red = 255, Green = 0, Blue = 0;
String text = "Easy Tech";
String RGB;
int pixelPerChar = 5, RGB_Completed = 0;
int Delay, Brightness;
const uint16_t colors[] = {matrix.Color(Green, Red, Blue)};

// matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };//matrix.Color(Red, Green, Blue),

void initdata() {

int Speed = EEPROM.read(0);
if (Speed == NULL || Speed == 0) {
Delay = 100;
}
else {
Delay = Speed;
}

int bright = EEPROM.read(5);
if (bright == NULL || bright == 0) {
Brightness = 40;
}
else {
Brightness = bright;
}

int r = EEPROM.read(10);
if (r == NULL) {
Red = 0;
}
else {
Red = r;
}

int g = EEPROM.read(15);
if (g == NULL) {
Green = 255;
}
else {
Green = g;
}

int b = EEPROM.read(20);
if (b == NULL) {
Blue = 0;
}
else {
Blue = b;
}
char data[100]; //Max 100 Bytes
int len = 0;
char k;
String Text = "";
k = EEPROM.read(50);
while (k != '\0' && len < 500) //Read until null character
{
k = EEPROM.read(50 + len);
data[len] = k;
Text += k;
len++;
}
data[len] = '\0';

if (Text == NULL) {
text = "EASY TECH";
}
else {
text = Text;
}
Serial.println(Speed);
Serial.println(Brightness);
Serial.println(Red);
Serial.println(Green);
Serial.println(Blue);
Serial.println(text);

}

void setup() {

Serial.begin(115200);
ESP_BT.begin(9600);
EEPROM.begin();
initdata();
// Serial.println("Start");
const uint16_t colors[] = {matrix.Color(Green, Red, Blue)};
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(Brightness);
matrix.setTextColor(colors[0]);
//matrix.setTextColor(matrix.Color(Green,Red,Blue));
}

int x = matrix.width();
int pass = 0;

void loop() {

while (ESP_BT.available()) {
char ReadChar = (char)ESP_BT.read();
Serial.println(ReadChar);

// Right parentheses ) indicates complet of the string
if (ReadChar == ')' || ReadChar == '}' || ReadChar == ']') {
  if (ReadChar == ')' ) {
    RGB_Completed = 1;
  }
  
  if (ReadChar == '}') {
    RGB_Completed = 2;
  }
  
  if (ReadChar == ']') {
    RGB_Completed = 3;
  }
}

else {
  RGB += ReadChar;
}

}

if (RGB_Completed != 0) {
if (RGB_Completed == 1) {
Light_RGB_LED();
RGB_Completed = 0;
}

if (RGB_Completed == 2) {
  text = RGB;
  int _size = text.length();
  int i;
  
  for (i = 0; i < _size; i++) {
    EEPROM.write(50 + i, text.charAt(i));
    Serial.println(text.charAt(i));
  }
  
  EEPROM.write(50 + _size, '\0'); //Add termination null character for String Data

  RGB_Completed = 0;
  RGB = "";
}

if (RGB_Completed == 3) {
  int val = RGB.toInt();
  if (val > 0 && val <= 100) {
    if (val == 0) {
      val = 1;
    }
    Delay = (100 - val) * 2.5;
    //scroll(Delay);
    EEPROM.write(0, Delay);
  }
  else {
    val = val - 100;
    matrix.setBrightness(val);
    EEPROM.write(5, val);
  }

  RGB = "";
  RGB_Completed = 0;
}

}

if (RGB_Completed == 0) {
//. Serial.println(RGB_Completed);
scroll();
}
}

void scroll() {
//Serial.println(text);
int maxDisplacement = text.length() * pixelPerChar + matrix.width();
matrix.fillScreen(0);
matrix.setCursor(x, 0);

matrix.print(text);
if (--x < -maxDisplacement) {
x = matrix.width();

if (++pass >= 1) {
  pass = 0;
  // matrix.setTextColor(colors[pass]);
  matrix.setTextColor(matrix.Color(Green, Red, Blue));
  //  matrix.setTextColor(matrix.Color(Red,Green,Blue));
}

}

matrix.show();
delay(Delay);
}

void Light_RGB_LED() {

int SP1 = RGB.indexOf('.');
int SP2 = RGB.indexOf('.', SP1 + 1);
int SP3 = RGB.indexOf('.', SP2 + 1);
String R = RGB.substring(0, SP1);
String G = RGB.substring(SP1 + 1, SP2);
String B = RGB.substring(SP2 + 1, SP3);
Red = R.toInt(); Green = G.toInt(); Blue = B.toInt();
// Serial.println(R);
matrix.setTextColor(matrix.Color(Green, Red, Blue));
EEPROM.write(10, Red); EEPROM.write(15, Green); EEPROM.write(20, Blue);
RGB = "";

}

You didn't insert code in code tags, try again.

Choose another board with more memory - for example Mega, ESP8266, RP2040 etc

1 Like

#include <SoftwareSerial.h>
#include "Arduino.h"
#include <Wire.h>//Include libraries: SoftwareSerial & Wire
SoftwareSerial ESP_BT(0, 1); //Define PIN11 & PIN12 as RX and TX pins

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>

#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 5

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = 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_GRBW Pixels are wired for GRBW bitstream (RGB+W NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// Example for NeoPixel Shield. In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino. When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order. The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(
32, //Select LEDs of each row (15 in my case)
8, //Select amount of rows (7 in my case)
PIN,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + //Define first data pin (right bottom corner is my first pin)
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG, //Define the type of connection (in a zig zag connections and divided by rows not columns)
NEO_RGB + NEO_KHZ800);

int Red = 255, Green = 0, Blue = 0;
String text = "Easy Tech";
String RGB;
int pixelPerChar = 5, RGB_Completed = 0;
int Delay, Brightness;
const uint16_t colors[] = {matrix.Color(Green, Red, Blue)};

// matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };//matrix.Color(Red, Green, Blue),

void initdata() {

int Speed = EEPROM.read(0);
if (Speed == NULL || Speed == 0) {
Delay = 100;
}
else {
Delay = Speed;
}

int bright = EEPROM.read(5);
if (bright == NULL || bright == 0) {
Brightness = 40;
}
else {
Brightness = bright;
}

int r = EEPROM.read(10);
if (r == NULL) {
Red = 0;
}
else {
Red = r;
}

int g = EEPROM.read(15);
if (g == NULL) {
Green = 255;
}
else {
Green = g;
}

int b = EEPROM.read(20);
if (b == NULL) {
Blue = 0;
}
else {
Blue = b;
}
char data[100]; //Max 100 Bytes
int len = 0;
char k;
String Text = "";
k = EEPROM.read(50);
while (k != '\0' && len < 500) //Read until null character
{
k = EEPROM.read(50 + len);
data[len] = k;
Text += k;
len++;
}
data[len] = '\0';

if (Text == NULL) {
text = "EASY TECH";
}
else {
text = Text;
}
Serial.println(Speed);
Serial.println(Brightness);
Serial.println(Red);
Serial.println(Green);
Serial.println(Blue);
Serial.println(text);

}

void setup() {

Serial.begin(115200);
ESP_BT.begin(9600);
EEPROM.begin();
initdata();
// Serial.println("Start");
const uint16_t colors[] = {matrix.Color(Green, Red, Blue)};
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(Brightness);
matrix.setTextColor(colors[0]);
//matrix.setTextColor(matrix.Color(Green,Red,Blue));
}

int x = matrix.width();
int pass = 0;

void loop() {

while (ESP_BT.available()) {
char ReadChar = (char)ESP_BT.read();
Serial.println(ReadChar);

// Right parentheses ) indicates complet of the string
if (ReadChar == ')' || ReadChar == '}' || ReadChar == ']') {
  if (ReadChar == ')' ) {
    RGB_Completed = 1;
  }
  
  if (ReadChar == '}') {
    RGB_Completed = 2;
  }
  
  if (ReadChar == ']') {
    RGB_Completed = 3;
  }
}

else {
  RGB += ReadChar;
}

}

if (RGB_Completed != 0) {
if (RGB_Completed == 1) {
Light_RGB_LED();
RGB_Completed = 0;
}

if (RGB_Completed == 2) {
  text = RGB;
  int _size = text.length();
  int i;
  
  for (i = 0; i < _size; i++) {
    EEPROM.write(50 + i, text.charAt(i));
    Serial.println(text.charAt(i));
  }
  
  EEPROM.write(50 + _size, '\0'); //Add termination null character for String Data

  RGB_Completed = 0;
  RGB = "";
}

if (RGB_Completed == 3) {
  int val = RGB.toInt();
  if (val > 0 && val <= 100) {
    if (val == 0) {
      val = 1;
    }
    Delay = (100 - val) * 2.5;
    //scroll(Delay);
    EEPROM.write(0, Delay);
  }
  else {
    val = val - 100;
    matrix.setBrightness(val);
    EEPROM.write(5, val);
  }

  RGB = "";
  RGB_Completed = 0;
}

}

if (RGB_Completed == 0) {
//. Serial.println(RGB_Completed);
scroll();
}
}

void scroll() {
//Serial.println(text);
int maxDisplacement = text.length() * pixelPerChar + matrix.width();
matrix.fillScreen(0);
matrix.setCursor(x, 0);

matrix.print(text);
if (--x < -maxDisplacement) {
x = matrix.width();

if (++pass >= 1) {
  pass = 0;
  // matrix.setTextColor(colors[pass]);
  matrix.setTextColor(matrix.Color(Green, Red, Blue));
  //  matrix.setTextColor(matrix.Color(Red,Green,Blue));
}

}

matrix.show();
delay(Delay);
}

void Light_RGB_LED() {

int SP1 = RGB.indexOf('.');
int SP2 = RGB.indexOf('.', SP1 + 1);
int SP3 = RGB.indexOf('.', SP2 + 1);
String R = RGB.substring(0, SP1);
String G = RGB.substring(SP1 + 1, SP2);
String B = RGB.substring(SP2 + 1, SP3);
Red = R.toInt(); Green = G.toInt(); Blue = B.toInt();
// Serial.println(R);
matrix.setTextColor(matrix.Color(Green, Red, Blue));
EEPROM.write(10, Red); EEPROM.write(15, Green); EEPROM.write(20, Blue);
RGB = "";

}

i have used Arduino Mega 2560 but same problem

Exactly the same problem?
That's strange.
I guess we'll have to wait a while for the code.
Please try to eliminate misleading or incorrect comments.

ok, i will do that.
Thank you in advance, anyway now I have to get to work.
I will wait for your answer.
Until then

You hardly will get an answer without of correct inserted code.

Please also explain what you meant as "code doesn't work"?

Compile errors? The board frozen after start? Something else?

1 Like

The board frozen

Is there any hope that we will ever see the code?