Adafruit RGB LED Matrix Library and Software Serial library

Hi there,

I am currently working on a project which involves a 64x32 LED Matrix board, an Arduino Mega and an AT-09 Bluetooth low energy module. Data is recieved by the module and interpreted on the Mega. This data should then be displayed on the LED matrix board.

At the moment I have both parts working separately, the data is being recieved correctly and the LED matrix board is displaying data correctly. However when I try integrate both of them together, that is get the data recieved from the bluetooth module and display that onto the LED board something goes wrong?!

After reading another post on this topic (Arduino Forum) I believe the problem is down to the "RGBmatrixPanel" and "SoftwareSerial" working with one another. I have tried the solution given on the post above however this did not seem to work, so I was wondering if any one has any ideas how to get round this problem?

The problem only seems to be happening in the "setup" function, when the matrix is initalised. Which I found to be the case when looking at the outputs on the serial monitor.

With the code below (without the matrix being initialised),

#include <SoftwareSerial.h>
#include <RGBmatrixPanel.h>

SoftwareSerial mySerial(50,5); // RX, TX
int PIN_EN_OUT = 4;
int PIN_STATE_IN = 5;

#define CLK 11 
#define OE   9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3

const char* stocks[][7] = {
  {"","","","","","",""},
  {"","","","","","",""},
  {"","","","","","",""},
  {"","","","","","",""},
  {"","","","","","",""}
};

bool previousEnd = false;
int stockNumberSTM = 0;
int openP;
int currentP;
int x = 0;
int y = 0;
bool full = false;

// BEFORE DATA IS SENT IT MUST BE IN UTF8 FORMAT OR STRING FORMAT
RGBmatrixPanel matrix(A,B,C,D,CLK,LAT,OE,true,64);

void setup() {
  // Set up communication
    // Initialise the LED Display
  mySerial.begin(9600);
  Serial.begin(9600);

}
char reply[1000];
void readSerial(){
  delay(100);
  char stock0[1000];
  int i = 0;
  while (mySerial.available()) {
    delay(100);
    reply[i] = mySerial.read();
    delay(100);
    i += 1;
    delay(100);
  }
  reply[i] = '\0';
  if(strlen(reply) > 0){
    delay(50);
    char* testArray = strtok(reply,"-");

    if(testArray == "CLEARED" ||"CLLEARED"){
      y = 0;
      x = 0;
      full = false;
      for(int v =0; v<5; v++){
        for(int g =0; g<7; g++){
         stocks[v][g] = "";
        }
     }
    }

    while(testArray != NULL) {
      Serial.println(y);
      Serial.println(x);
      Serial.println(testArray);
      mySerial.println(testArray);
      delay(100);
      stocks[y][x] = testArray;
      x += 1;
      if (x>6){
        x = 0;
        y += 1;
      }
      if(y>4) {
        y = 0;
       }
       if(y == 4 && x == 6){
        full = true;
        Serial.println("FULL");
        mySerial.println("FULL");
       }
     
     
      delay(100);
      testArray = strtok(NULL,"-");
    }
      
    for(int v =0; v<5; v++){
      for(int g =0; g<7; g++){
        Serial.println(stocks[v][g]);
        }
     }
    }

}


void loop() {
  mySerial.listen(); // doesn't change the output 
  readSerial();
  delay(100);

}

the output was as required (see attatched). However when changing the "setup" function by initalising the LED matrix board, like so

void setup() {
  // Set up communication
    // Initialise the LED Display
  matrix.begin();
  mySerial.begin(9600);
  Serial.begin(9600);
}

the output in the serial monitor is lots of symbols (see attatched image).
Any help would be greatly appreciated, I am new to Ardunio so if you spot ways in which my code can be changed or optimised that would be great too!

Thanks!

errorOutput.PNG

errorOutput.PNG