Neomatrix Serial port messaging

Hi anyone
I am trying send messages via serial port and arduino uno to neopixelmatrix, but i can´t read de serial port data and paste to neopixel, do you know how can i do it

What problem are you experiencing?
What kind of messages are you sending? E.g. text from a trminal program like Serial monitor? Or binary data?

What does that mean?

Ok this is my problem
if (Serial.available() > 0)
data = Serial.read(); // copy
else
{
matrix.fillScreen(0);
matrix.setCursor(2,14);
matrix.print(F(data)); // paste
matrix.show();
}
and the error message is:
Arduino:1.8.15 (Windows 10), Tarjeta:"Arduino Uno"

In file included from D:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

             from sketch\Presentador_V2.0.ino.cpp:1:

D:\OneDrive\PDF\Imágenes\Documents\Arduino\matrixtest\Presentador_V2.0\Presentador_V2.0.ino: In function 'void loop()':

D:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:38:74: error: initializer fails to determine size of '__c'

#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))

                                                                      ^

D:\OneDrive\PDF\Imágenes\Documents\Arduino\matrixtest\Presentador_V2.0\Presentador_V2.0.ino:108:18: note: in expansion of macro 'F'

D:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:38:74: error: array must be initialized with a brace-enclosed initializer

#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))

                                                                      ^

D:\OneDrive\PDF\Imágenes\Documents\Arduino\matrixtest\Presentador_V2.0\Presentador_V2.0.ino:108:18: note: in expansion of macro 'F'

exit status 1

Error compilando para la tarjeta Arduino Uno.

Este informe podría contener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.

and i use serial terminal

Please post your full code. The easiest to do it correctly is

  1. In the IDE, use tools -> autoformat; this will sort out indentations.
  2. In the IDE, use edit -> copy for forum; this will copy the code to the clipboard.
  3. In a new reply, paste the copied code.
  4. Save the reply.
#include <Mouse.h>

// Adafruit_NeoMatrix example for tiled NeoPixel matrices.  Scrolls
// 'Howdy' across three 10x8 NeoPixel grids that were created using
// NeoPixel 60 LEDs per meter flex strip.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/AGENCYR9pt7b.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 5

// Declaracion de variable comunicacion

// Comandos
//    01 - Configuracion
//    02 - Datos para un Renglon 5 caracteres ascii
//   Trama comando configuracion
//   0x02 "01" "1"


// MATRIX DECLARATION:
// Parameter 1 = width of EACH NEOPIXEL MATRIX (not total display) // Se refiere al tamaño de la matriz de leds 8x8 16x16 32x64, si es el caso de una pantalla
// Parameter 2 = height of each matrix                             Formada con varias matrices se indica el arrego de m renglones n columnas
// Parameter 3 = number of matrices arranged horizontally          numero de matrices que forman horizontalmente el renglon (n columnas)
// Parameter 4 = number of matrices arranged vertically            Numero de matrices que forma  verticalmente  el renglol (n renglones9
// Parameter 5 = pin number (most are valid)
// Parameter 6 = 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 FIRST MATRIX; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs WITHIN EACH MATRIX are
//     arranged in horizontal rows or in vertical columns, respectively;
//     pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns WITHIN
//     EACH MATRIX proceed in the same order, or alternate lines reverse
//     direction; pick one.
//   NEO_TILE_TOP, NEO_TILE_BOTTOM, NEO_TILE_LEFT, NEO_TILE_RIGHT:
//     Position of the FIRST MATRIX (tile) in the OVERALL DISPLAY; pick
//     two, e.g. NEO_TILE_TOP + NEO_TILE_LEFT for the top-left corner.
//   NEO_TILE_ROWS, NEO_TILE_COLUMNS: the matrices in the OVERALL DISPLAY
//     are arranged in horizontal rows or in vertical columns, respectively;
//     pick one or the other.
//   NEO_TILE_PROGRESSIVE, NEO_TILE_ZIGZAG: the ROWS/COLUMS OF MATRICES
//     (tiles) in the OVERALL DISPLAY proceed in the same order for every
//     line, or alternate lines reverse direction; pick one.  When using
//     zig-zag order, the orientation of the matrices in alternate rows
//     will be rotated 180 degrees (this is normal -- simplifies wiring).
//   See example below for these values in action.
// Parameter 7 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 pixels)
//   NEO_GRB     Pixels are wired for GRB bitstream (v2 pixels)
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA v1 pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip)

// Example with three 10x8 matrices (created using NeoPixel flex strip --
// these grids are not a ready-made product).  In this application we'd
// like to arrange the three matrices side-by-side in a wide display.
// The first matrix (tile) will be at the left, and the first pixel within
// that matrix is at the top left.  The matrices use zig-zag line ordering.
// There's only one row here, so it doesn't matter if we declare it in row
// or column order.  The matrices use 800 KHz (v2) pixels that expect GRB
// color data.
//

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16, 16, 2, 1, PIN,
                            NEO_TILE_TOP   + NEO_TILE_RIGHT   + NEO_TILE_ROWS   + NEO_TILE_PROGRESSIVE +
                            NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
                            NEO_RGB + NEO_KHZ800);



const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255)
};

void setup() {
  Serial.begin(9600);
  matrix.setFont(&AGENCYR9pt7b);
  matrix.setTextSize(1, 1);
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(20);
  matrix.setTextColor(colors[0]);
}

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


void loop() {
  if (Serial.available() > 0)
    dat_ser = Serial.read();

  else
  {
    matrix.fillScreen(0);
    matrix.setCursor(2, 14);

    matrix.print(F(dat_ser));
    if (--x < -60) {
      x = matrix.width();
      if (++pass >= 3) pass = 0;
      matrix.setTextColor(colors[pass]);
    }
  }
  matrix.show();
  delay(100);
  teventa++;


}

That doesn't seem to be the code that causes the given error. I get the below error

error: 'dat_ser' was not declared in this scope
dat_ser = Serial.read();

And the other problem is the use of the F macro in this line

    matrix.print(F(dat_ser));

Change it to

    matrix.print(dat_ser);

Not quite sure why you include Mouse.h on an Uno.

Hi!!! Again...

I could fix the program but now i have a nice trouble...

I have a display with 2 tiled matrix 16x16 and i use neo_matrix font to fill with bigger font when i set 2 horizontal matrix and 1 vertical matrix and activate serial port com the neopixel dont work but if i use 1 horizontal and 1 vertical the systems works very goog any suggestion?


// Adafruit_NeoMatrix example for tiled NeoPixel matrices.  Scrolls
// 'Howdy' across three 10x8 NeoPixel grids that were created using
// NeoPixel 60 LEDs per meter flex strip.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/AGENCYR9pt7b.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 6
#define st_t  0x00
#define end_t 0x01
String  dat_ser;
String dat_serb;
float a=12.3;
char dat_sera;
char contador;
char dat_c[5];
char end_receive;
int i;
// Declaracion de variable comunicacion

// Comandos
//    01 - Configuracion
//    02 - Datos para un Renglon 5 caracteres ascii
//   Trama comando configuracion
//   0x02 "01" "1"


// MATRIX DECLARATION:
// Parameter 1 = width of EACH NEOPIXEL MATRIX (not total display) // Se refiere al tamaño de la matriz de leds 8x8 16x16 32x64, si es el caso de una pantalla
// Parameter 2 = height of each matrix                             Formada con varias matrices se indica el arrego de m renglones n columnas
// Parameter 3 = number of matrices arranged horizontally          numero de matrices que forman horizontalmente el renglon (n columnas)
// Parameter 4 = number of matrices arranged vertically            Numero de matrices que forma  verticalmente  el renglol (n renglones9
// Parameter 5 = pin number (most are valid)
// Parameter 6 = 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 FIRST MATRIX; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs WITHIN EACH MATRIX are
//     arranged in horizontal rows or in vertical columns, respectively;
//     pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns WITHIN
//     EACH MATRIX proceed in the same order, or alternate lines reverse
//     direction; pick one.
//   NEO_TILE_TOP, NEO_TILE_BOTTOM, NEO_TILE_LEFT, NEO_TILE_RIGHT:
//     Position of the FIRST MATRIX (tile) in the OVERALL DISPLAY; pick
//     two, e.g. NEO_TILE_TOP + NEO_TILE_LEFT for the top-left corner.
//   NEO_TILE_ROWS, NEO_TILE_COLUMNS: the matrices in the OVERALL DISPLAY
//     are arranged in horizontal rows or in vertical columns, respectively;
//     pick one or the other.
//   NEO_TILE_PROGRESSIVE, NEO_TILE_ZIGZAG: the ROWS/COLUMS OF MATRICES
//     (tiles) in the OVERALL DISPLAY proceed in the same order for every
//     line, or alternate lines reverse direction; pick one.  When using
//     zig-zag order, the orientation of the matrices in alternate rows
//     will be rotated 180 degrees (this is normal -- simplifies wiring).
//   See example below for these values in action.
// Parameter 7 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 pixels)
//   NEO_GRB     Pixels are wired for GRB bitstream (v2 pixels)
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA v1 pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip)

// Example with three 10x8 matrices (created using NeoPixel flex strip --
// these grids are not a ready-made product).  In this application we'd
// like to arrange the three matrices side-by-side in a wide display.
// The first matrix (tile) will be at the left, and the first pixel within
// that matrix is at the top left.  The matrices use zig-zag line ordering.
// There's only one row here, so it doesn't matter if we declare it in row
// or column order.  The matrices use 800 KHz (v2) pixels that expect GRB
// color data.
//

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16,16,2, 1, PIN,
NEO_TILE_TOP   + NEO_TILE_RIGHT   + NEO_TILE_ROWS   + NEO_TILE_PROGRESSIVE +
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_RGB + NEO_KHZ800);



const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255)
};

void setup() {
  Serial.begin(9600);
 
  //matrix.setTextSize(1, 1);
  matrix.begin();
  matrix.setFont(&AGENCYR9pt7b);
  matrix.setTextWrap(false);
  matrix.setBrightness(20);
  matrix.setTextColor(colors[0]);
  i=0;
}

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

void loop() {
  if (Serial.available() >0  )
  {
      dat_sera = Serial.read();
      if (dat_sera!= 10)
      {
        dat_c[i]=dat_sera;
        i++;
      }
  }
      else
      {
         i=0;
         dat_serb=atof(dat_c);
       //  Serial.print(dat_serb);
         matrix.fillScreen(0);
         matrix.setCursor(2, 14);
         matrix.print(dat_serb);
      }
      if (--x < -36) {
         x = matrix.width();
         if (++pass >= 3) pass = 0;
           matrix.setTextColor(colors[pass]);
      }
 
  matrix.show();
  delay(100);
  teventa++;


}

I'm not familiar with NeoMatrix so can't advise.

If you're running this on an Uno, you might be running out of memory. 16x16x2=512 pixels, multiply by 3 for the three colours and you're using 1536 bytes of RAM. Not sure how this is affected by the layout, though.

True, you may be right, I had not seen it that way, I was guided by the data that the compiler gives ... thanks

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