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.
