Sending 2D array maze map from one arduino to another arduino via bluetooth

Hello Everyone,

Well I'm designing a maze searching robot where one robot attach with it a sensor(PING Ultrasonic Distance Sensor [#28015]) to enter a maze and solve it, it should on the same time map the maze and transmit map to the another robot that doesn't have any sensors for second robot to solve maze based on the information collected. The map is transmitted via Bluetooth (HC-05) and the structure of the maze is in 2D array, I tried to transmit the map but the only thing that I get value can anyone help me out?

Receiver Code:
(Arduino Uno)

#include<SoftwareSerial.h>
const int rxPin = 0;
const int txPin = 1;
SoftwareSerial mySerial(rxPin,txPin);//RX,TX.
byte packet;

void setup() 
{  
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  mySerial.begin(9600);
}


void loop()
{
  if(mySerial.available != 0)
  {
    byte inData = mySerial.read();
    Serial.println(inData);
    packet ++;
  }
}

Maze Solver:
(Arduino Mega 2560)

//////////// Initializing Libraries ////////////
#include <Servo.h>
#include <SD.h>
#include "Maze_Map.h"

//////////// Initialising Varaibles ////////////
int servoPin = 2;
Servo servo;
const int pingPin = 3;
unsigned int duration,inches;
int leftscan,centerscan,rightscan;
boolean scan = true;
int ledPin =  53;                  // Status LED connected to digital pin 13
Maze<4,6> maze;                    // Defining the rows and columns of the maze

//////////// Main Program ////////////
void setup() {
  // put your setup code here, to run once:
  pinMode(ledPin, OUTPUT);         // set the Pin to output 
  servo.attach(servoPin);
  Serial.begin(9600);
  Serial1.begin(38400);            // Turn on Bluetooth Serial
  Serial2.begin(38400);            // Turn on OpenLogger
  delay(1000);                     // Wait a second for OpenLog to initiate 
  maze.mouseRow = 4;
  maze.mouseColumn = 1;
  maze.mouseHeading = NORTH;
  Serial.println("                      Initial Maze                          ");
  maze.solve();
  maze.print();
  Serial.println("                       Final Maze                           ");
}

void loop() {
  // put your main code here, to run repeatedly:
  SensorScan();
  maze.solve();
  maze.print();
  Serial1.write(maze.print());
}

//////////// Functions ////////////

// PING Sensor Function //
int Sensor()
{
  pinMode(pingPin, OUTPUT);          // Set pin to OUTPUT
  digitalWrite(pingPin, LOW);        // Ensure pin is low
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);       // Start ranging
  delayMicroseconds(5);              // with 5 microsecond burst
  digitalWrite(pingPin, LOW);        // End ranging
  pinMode(pingPin, INPUT);           // Set pin to INPUT
  duration = pulseIn(pingPin, HIGH); // Read echo pulse
  inches = duration / 74 / 2;        // Convert to inches
  delay(25);                         // Short delay
}

// Conversion Function //
long microsecondsToInches(long microseconds) 
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) 
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

// Sensor Scan + Direction Change Function //
int SensorScan()
{
  // Initialising Varaibles //
  int leftscan,centerscan,rightscan;
  char Direction;
  const int SafeDistance = 5;
  // Scanning the Perimeter //
  // Scan Left //
  servo.write(180);                      // Rotating the servo to 180 degrees
  delay(2000);                           // Adding Delay to extend the durtation for the servo motor to be at an angle of 180 degrees
  leftscan = Sensor();                   // Using the Sensor function to detect if there is wall or not
  leftscan = inches;                     // Equating the distance to the leftscan variable
  Serial.print("LeftScan: ");
  Serial.println(leftscan);
  // Scan Center //
  servo.write(90);                       // Rotating the servo to 90 degrees
  delay(2000);                           // Adding Delay to extend the durtation for the servo motor to be at an angle of 90 degrees
  centerscan = Sensor();                 // Using the Sensor function to detect if there is wall or not
  centerscan = inches;                   // Equating the distance to the centerscan variable
  Serial.print("CenterScan: ");
  Serial.println(centerscan);
  // Scan Right //
  servo.write(0);                        // Rotating the servo to 0 degrees
  delay(2000);                           // Adding Delay to extend the durtation for the servo motor to be at an angle of 0 degrees
  rightscan = Sensor();                  // Using the Sensor function to detect if there is wall or not
  rightscan = inches;                    // Equating the distance to the rightscan variable
  Serial.print("RightScan: ");
  Serial.println(rightscan);
  // Return To Center //
  servo.write(90);                       // Rotating the servo to 90 degrees
  delay(5000);                           // Adding Delay to extend the durtation for the servo motor to be at an angle of 90 degrees
  
  // Direction Change //
  if (centerscan > leftscan && centerscan > rightscan)
  {
    maze.mouseHeading = NORTH;
    maze.mouseRow -= 1;
    Direction = 'F';
    Serial.print("Direction: ");
    Serial.println(Direction);
    // Adding Walls //
    if (centerscan > leftscan && centerscan > rightscan)
  {
    maze.addWalls(WEST);
    maze.addWalls(EAST);
  }
  }
  if (leftscan > rightscan && leftscan > centerscan)
  {
    maze.mouseHeading = WEST;
    maze.mouseColumn -= 1;
    Direction = 'L';
    Serial.print("Direction: ");
    Serial.println(Direction);
    // Adding Walls //
    if (leftscan > rightscan && leftscan > centerscan)
  {
    maze.addWalls(NORTH);
    maze.addWalls(EAST);
  }
  }
  if (rightscan > leftscan && rightscan > centerscan)
  {
    maze.mouseHeading = EAST;
    maze.mouseColumn += 1;
    Direction = 'R';
    Serial.print("Direction: ");
    Serial.println(Direction);
    // Adding Walls //
    if (rightscan > leftscan && rightscan > centerscan)
  {
    maze.addWalls(NORTH);
    maze.addWalls(WEST);
  }
  }
//// Data Transmission //
//  pinMode(ledPin, OUTPUT);          // Set pin to OUTPUT
//  digitalWrite(ledPin, HIGH);       // Turn LED on
//  maze.solve();
//  maze.print();
//  Serial1.write(maze.print());
//  delay(2000);
//  digitalWrite(ledPin, LOW);        // Turn LED off 
}

Maze_Map.h:

#include <Arduino.h>

#define NORTH 0
#define EAST 1
#define SOUTH 2
#define WEST 3

template <byte ROWS,byte COLUMNS>
class Maze
{
private:
    // vertical walls array
    boolean verticalWalls[ROWS][COLUMNS+1];

    // horizontal walls array
    boolean horizontalWalls[ROWS+1][COLUMNS];

public:
    // value array
    byte values[ROWS][COLUMNS];
    
    byte mouseRow;
    byte mouseColumn;
    byte mouseHeading;

    //Constructor method (called when the maze is created)
    Maze()
    {
        //initialize verticalWalls (add exterior walls)
        for(byte i = 0;i < ROWS;i++)
        {
            for(byte j = 0;j<COLUMNS+1;j++)
            {
                if(j==0 || j == COLUMNS)
                {
                    verticalWalls[i][j] = true;
                }
            }
        }

        //initialize horizontalWalls (add exterior walls)
        for(byte i = 0;i < ROWS + 1;i++)
        {
            for(byte j=0;j<COLUMNS;j++)
            {
                if(i==0 || i==ROWS)
                {
                    horizontalWalls[i][j]=true;
                }
            }
        }
    }
    
    //Add your code here
    void solve()
    {
      for (byte i = 0; i < ROWS; i++)
      {
        for (byte j = 0; j < COLUMNS; j++)
        {
          values[i][j] = 5;
        }
      }
    }

    void addWalls(byte CardinalDirection)
    {
      switch(CardinalDirection)
      {
        case NORTH:
        horizontalWalls[mouseRow][mouseColumn] = true;
        break;
        case EAST:
        verticalWalls[mouseRow][mouseColumn + 1] = true;
        break;
        case SOUTH:
        horizontalWalls[mouseRow + 1][mouseColumn] = true;
        break;
        case WEST:
        verticalWalls[mouseRow][mouseColumn] = true;
        break;
      }
    }

    void removeaddWalls(byte CardinalDirection)
    {
      switch(CardinalDirection)
      {
        case NORTH:
        horizontalWalls[mouseRow][mouseColumn] = false;
        break;
        case EAST:
        verticalWalls[mouseRow][mouseColumn + 1] = false;
        break;
        case SOUTH:
        horizontalWalls[mouseRow + 1][mouseColumn] = false;
        break;
        case WEST:
        verticalWalls[mouseRow][mouseColumn] = false;
        break;
      }
    }
    
    /*Do not change or add code below this line
    
    NanoMouseMaze Print Function Version 2
    This version of the print function has been modified to print
    any size maze (the previous version could not print large
    mazes) and to work with the btMonitor Android App I wrote,
    which is available through my free online course at:
    http://udemy.com/nanomouse
    Scroll down to "Wireless Debugging with the Bluetooth Module"
    and go to the Downloadable Materials section of the lecture.*/
    
    byte print()
    {
        for(byte i = 0;i < 2*ROWS+1;i++)
        {
            for(byte j = 0;j < 2*COLUMNS+1;j++)
            {
                //Add Horizontal Walls
                if(i%2 == 0 && j%2 == 1)
                {
                    if(horizontalWalls[i/2][j/2] == true)
                    {
                        Serial.print(" ---");
                        Serial1.print(" ---");
                    }
                    else
                    {
                        Serial.print("    ");
                        Serial1.print("    ");
                    }
                }

                //Add Vertical Walls
                if(i%2 == 1 && j%2 == 0)
                {
                    if(verticalWalls[i/2][j/2] == true)
                    {
                        Serial.print("|");
                        Serial1.print("|");
                    }
                    else
                    {
                        Serial.print(" ");
                        Serial1.print(" ");
                    }
                }

                //Add Flood Fill Values
                if(i%2 == 1 && j%2== 1)
                {
                    if((i-1)/2 == mouseRow && (j-1)/2 == mouseColumn)
                    {
                        if(mouseHeading == NORTH)
                        {
                            Serial.print(" ^ ");
                            Serial1.print(" ^ ");
                        }
                        else if(mouseHeading == EAST)
                        {
                            Serial.print(" > ");
                            Serial1.print(" > ");
                        }
                        else if(mouseHeading == SOUTH)
                        {
                            Serial.print(" v ");
                            Serial1.print(" v ");
                        }
                        else if(mouseHeading == WEST)
                        {
                            Serial.print(" < ");
                            Serial1.print(" < ");
                        }
                    }
                    else
                    {
                        byte value = values[(i-1)/2][(j-1)/2];
                        if(value >= 100)
                        {
                            Serial.print(value);
                            Serial1.print(value);
                        }
                        else
                        {
                            Serial.print(" ");
                            Serial.print(value);
                            Serial1.print(" ");
                            Serial1.print(value);
                        }
                        if(value < 10)
                        {
                            Serial.print(" ");
                            Serial1.print(" ");
                        }
                    }
                }
            }
            Serial.print("\n");
            Serial1.print("\n");
        }
        Serial.print("\n");
        Serial1.print("\n");
    }
};[code]

[/code]

Make certain that you understand how to transmit data from one Arduino to another and get that to work, before you add that feature to an existing program.

const int rxPin = 0;
const int txPin = 1;
SoftwareSerial mySerial(rxPin,txPin);//RX,TX.
byte packet;

void setup()
{  
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  mySerial.begin(9600);

YOU CAN NOT DO SOFTWARE SERIAL ON THE HARDWARE SERIAL PINS WHILE ALSO DOING HARDWARE SERIAL ON THEM!