MAX7219 LED dot matrix display issues with serial communication

Hi everyone,
I have a problem with my new MAX7219 dot matrix display and serial communication. I can get the display to do all of the cool features, like scrolling text, etc. but I can't figure out how to use serial in order to change the text of the display. Here is my example code which works, but not quite properly:


String a;
// Include the required Arduino libraries:
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// Define hardware type, size, and output pins:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8
#define CS_PIN 3

// Create a new instance of the MD_Parola class with hardware SPI connection:
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

// Setup for software SPI:
// #define DATAPIN 2
// #define CLK_PIN 4
// MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);



void setup() {
  // Intialize the object:
  myDisplay.begin();
  // Set the intensity (brightness) of the display (0-15):
  myDisplay.setIntensity(0);
  // Clear the display:
  myDisplay.displayClear();
  Serial.begin(9600);

  pinMode(LED_BUILTIN, OUTPUT);


}

void loop() {

  if (Serial.available() > 0) {
    myDisplay.displayClear();
    myDisplay.setTextAlignment(PA_CENTER);
    myDisplay.displayClear();



    a = Serial.readString(); // read the incoming data as string

    Serial.println(a);

    myDisplay.print(a);



  }

}

So, what should happen is when I type something into the serial monitor, it should show up on the display. It'll show the text, but then add this strange character to the end of the text:

Any help on removing this last character is very much appreciated!
Thanks,
transistor_man.

Have you selected the no line endings option on the serial monitor. It looks like that extra thing at the end is the graphics equivalent of your line ending.

Alternitavely you can simply remove the last character from your string.

I just tried changing the endings option in the serial monitor, and it worked magically! :slight_smile:
Thank you. I feel a bit foolish not knowing something so simple, but I guess that's what the arduino forum is about!

Thanks again,
transistor_man

We get this question all the time about "printing" to an alphanumeric (LCD) display. :grin: