Strange character on LED matrix scoreboard serial data transfer

Hi All,

i have been playing around with this idea for a while i now have these sketches working but with a small problem.

Basically i want to have a scoreboard/counter on 4 LED matrix boards. I am using 1 UNO board to manage a counter sketch controlled by micro switches adding a value to a number. This then serial transmits the number to another UNO board controlling the 4 LED matrix (8X8 LED with MAX7219 from china over eBay)

I have it working but it displays a “q/p” like symbol after the score!

Can anyone shed some light on this issue and what i am doing wrong??

Image of the display issue (symbol after numbers- score should be 225)

counter & transmitter sketch

// set up a constant for the score switchPin
const int switchPin = 6;
const int switchPin2 = 7;

int hits = 0;

// variable to hold the value of the switchPin
int switchState = 0;
int switchState2 = 0;


void setup() { 
 Serial.begin(115200); 
  
  // set up the switch pin as an input
  pinMode(switchPin,INPUT);
  pinMode(switchPin2,INPUT);

}

void loop() {  
  // check the status of the switch
  switchState = digitalRead(switchPin);
  switchState2 = digitalRead(switchPin2);

  // compare the switchState to its previous state
     if (switchState == HIGH) {
      hits = hits + 10;
      
       Serial.println(hits);
   
    // end of for
        delay(300);
  }

    if (switchState2 == HIGH) {
      hits = hits + 1;
    
           Serial.println(hits);
          delay(300);
   
}

  }

Receiver and LED matrix display sketch

/ Use the MD_MAX72XX library to Print some text on the display
//
// Demonstrates the use of the library to print text.
//
// User can enter text on the serial monitor and this will display as a
// message on the display.

#include <MD_MAX72xx.h>

#define	PRINT(s, v)	{ Serial.print(F(s)); Serial.print(v); }

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may 
// need to be adapted
#define	MAX_DEVICES	4

#define	CLK_PIN		13  // or SCK
#define	DATA_PIN	11  // or MOSI
#define	CS_PIN		10  // or SS

// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Text parameters
#define	CHAR_SPACING	1	// pixels between characters

// Global message buffers shared by Serial and Scrolling functions
#define	BUF_SIZE	75
char message[BUF_SIZE] = {"SCORE"};
bool newMessageAvailable = true;

void readSerial(void)
{
  static uint8_t	putIndex = 0;

  while (Serial.available())
  {
    message[putIndex] = (char)Serial.read();
    if ((message[putIndex] == '\n') || (putIndex >= BUF_SIZE-3))	// end of message character or full buffer
    {
      // put in a message separator and end the string
      message[putIndex] = '\0';
      // restart the index for next filling spree and flag we have a message waiting
      putIndex = 0;
      newMessageAvailable = true;
    }
    else
      // Just save the next char in next location
      message[putIndex++];
  }
}

void printText(uint8_t modStart, uint8_t modEnd, char *pMsg)
// Print the text string to the LED matrix modules specified. 
// Message area is padded with blank columns after printing.
{
  uint8_t   state = 0;
  uint8_t	  curLen;
  uint16_t  showLen;
  uint8_t	  cBuf[8];
  int16_t   col = ((modEnd + 1) * COL_SIZE) - 1;

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);

  do     // finite state machine to print the characters in the space available
  {
    switch(state)
    {
      case 0:	// Load the next character from the font table
        // if we reached end of message, reset the message pointer
        if (*pMsg == '\0')
        {
          showLen = col - (modEnd * COL_SIZE);  // padding characters
          state = 2;
          break;
        }

        // retrieve the next character form the font file
        showLen = mx.getChar(*pMsg++, sizeof(cBuf)/sizeof(cBuf[0]), cBuf);
        curLen = 0;
        state++;
        // !! deliberately fall through to next state to start displaying

      case 1:	// display the next part of the character
        mx.setColumn(col--, cBuf[curLen++]);

        // done with font character, now display the space between chars
        if (curLen == showLen)  
        {
          showLen = CHAR_SPACING;
          state = 2;
        }
        break;

      case 2: // initialize state for displaying empty columns
        curLen = 0;
        state++;
        // fall through

      case 3:	// display inter-character spacing or end of message padding (blank columns)
        mx.setColumn(col--, 0);
        curLen++;
        if (curLen == showLen) 
          state = 0;
        break;

      default:
        col = -1;   // this definitely ends the do loop
    }
  } while (col >= (modStart * COL_SIZE));

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::ON); 
  
}

const char startOfNumberDelimiter = '<';
const char endOfNumberDelimiter   = '>';

void setup()
{
  mx.begin();

  Serial.begin(115200);
  Serial.print ("score");
}
  
  void processNumber (const long n)
{
 Serial.println (n);
 }  // end of processNumber
 
void processInput ()
 {
 static long receivedNumber = 0;
 static boolean negative = false;
 
 byte c = Serial.read ();
 
 switch (c)
   {
     
   case endOfNumberDelimiter:  
     if (negative) 
       processNumber (- receivedNumber); 
     else
       processNumber (receivedNumber); 

   // fall through to start a new number
   case startOfNumberDelimiter: 
     receivedNumber = 0; 
     negative = false;
     break;
     
   case '0' ... '9': 
     receivedNumber *= 10;
     receivedNumber += c - '0';
     break;
     
   case '-':
     negative = true;
     break;
     
   } // end of switch  
 }  // end of processInput


void loop() 
{
  readSerial();
  if (newMessageAvailable)
  {
    PRINT("\nProcessing new message: ", message);
    printText(0, MAX_DEVICES-1, message);
    newMessageAvailable = false;
  }
}

any help much apreciated!!

Can anyone help?

Somewhere you are processing a little too much data it looks like.
I don't really follow your code, but I would look at what happens after the 5 is sent out.
Maybe you need to fill the rest of the display after that with blank lines, versus the remnant of "SCORE" or whatever is there.