Serial Communication - One Arduino sending potentiometer value, other reading it

I have two Arduino Megas. One has a potentiometer hooked up to the A0 pin. I am converting the number this potentiometer reads to two bits and sending it through Serial. I want the second Arduino to be able to print the 0-1023 value. I would think that val[2] would give me this, but for some reason nothing is printing. I assume it's because it is not getting a signal from the other TX. When I put the Serial.print's outside of the if(Serial.available) section of my code, it prints an infinite number of zeros. Anyone know why?

Here's my TX code (TX light on Arduino is lighting up):

/*
  AnalogToSerial
  Reads an analog input on pin 0, outputs to TX.
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(19,18); // RX, TX
int data [2]; 
int potPin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
 
void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  pinMode(19, INPUT);
  pinMode(18, OUTPUT);
 
}
 
void loop() {
 
  val = analogRead(potPin);   // reads the value of the potentiometer (value between 0 and 1023)
  data[0] = val & 0xFF; //least significant 8 bit byte
  data[1] = (val >> 8); //most significant 2 bits
  
  Serial.print(data[0], HEX); 
  Serial.print(" ");
  Serial.println(data[1], HEX); 
 
  mySerial.write(data[0]); 
  mySerial.write(data[1]); //bytes sent
  delay(1);        // delay in between reads for stability
 
}

And here's the RX (RX light on this Arduino is NOT lighting up):

/*
  Analog Receive
  Reads a 10 bit serial stream in two bytes
  reassembles and converts to binary display using 8 LEDs
*/

#include <SoftwareSerial.h>
SoftwareSerial mySerial(19,18); // RX, TX
int val[4];    // variable to read the value from the analog pin
int i;
int LED[8] = {4,5,6,7,8,9,10,11};  // LED port array

//////////// Binary Conversion //////////////////////////////////////////////////////////
void binary(int dec) {
  int bval = dec/4;                                      // convert dec value to binary, scale to 8 bits
  for (i=0; i<8; i++) {
    if (bval%2==0) digitalWrite (LED[i],LOW);            // set LEDs accordingly
    else digitalWrite (LED[i],HIGH);
    bval=bval/2;
  }
}

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600); 
  pinMode(19, INPUT);
  pinMode(18, OUTPUT);
  for (i=0; i<8; i++) {
    pinMode (LED[i], OUTPUT);
  }
}

void loop() {

  if (mySerial.available()>1) {
    val[0]=mySerial.read();         // least significant 8 bits
    val[1]=mySerial.read();         // most significant 2 bits
    val[2] = val[1]<<8 | val[0];    // reassebled 10 bit value, sore in val[2]
    binary(val[2]);                 // convert to binary and display on LEDs

    Serial.print(val[1],HEX); Serial.print(" ");
    Serial.print(val[0],HEX); Serial.print(" ");
    Serial.println(val[2],HEX);
  }
}

Below is some servo/pot tx/rx code for servos that might be similar to what you want. You might skip the value mapping lines and just send the analog input 0-1023 values to the rx servo for procesing.

TX

//zoomkat multi pot/servo test 3-23-13
//includes dead band for testing and limit servo hunting
//view output using the serial monitor

#include <Servo.h> 
Servo myservo1;  //declare servos
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int potpin5 = 4;

int newval1, oldval1;  //pot input values
int newval2, oldval2;
int newval3, oldval3;
int newval4, oldval4;
int newval5, oldval5;

void setup() 
{
  Serial.begin(9600);  
  myservo1.attach(2);  
  myservo2.attach(3);
  myservo3.attach(4);
  myservo4.attach(5);
  myservo5.attach(6);
  Serial.println("testing multi pot servo");  
}

void loop()
{ 
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179); 
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){ //dead band 
    myservo1.write(newval1); //position the servo
    Serial.print(newval1); //print the new value for testing 
    Serial.print("a,");
    oldval1=newval1; //set the current old value
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
    myservo2.write(newval2);
    Serial.print(newval2);
    Serial.print("b,");
    oldval2=newval2;
  }

  newval3 = analogRead(potpin3);           
  newval3 = map(newval3, 0, 1023, 0, 179); 
  if (newval1 < (oldval3-2) || newval3 > (oldval3+2)){  
    myservo3.write(newval3);
    Serial.print(newval3);
    Serial.print("c,");
    oldval3=newval3;
  }

  newval4 = analogRead(potpin4);           
  newval4 = map(newval4, 0, 1023, 0, 179); 
  if (newval4 < (oldval4-2) || newval4 > (oldval4+2)){  
    myservo1.write(newval4);
    Serial.print(newval4);
    Serial.print("d,");
    oldval4=newval4;
  }

  newval5 = analogRead(potpin5);           
  newval5 = map(newval5, 0, 1023, 0, 179); 
  if (newval5 < (oldval5-2) || newval5 > (oldval5+2)){  
    myservo5.write(newval5);
    Serial.print(newval5);
    Serial.print("e,");
    oldval5=newval5;
  } 
  delay(50);  //to slow loop for testing, adjust as needed
}

RX

//zoomkat 11-22-12 simple delimited ',' string parse 
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added 
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control 
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded
}

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or combined like 30c,180b,70a,120d,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
        {
          Serial.print("writing Microseconds: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
        }
        else
        {   
          Serial.print("writing Angle: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
        }
         readString=""; //clears variable for new input
      }
    }  
    else {     
      readString += c; //makes the string readString
    }
  }
}

And here's the RX (RX light on this Arduino is NOT lighting up):

The RX and TX LEDs are connected to the ATMega16U2 and used with the hardware serial port 0 (Serial in short). So you would only see the RX flash when you send something from e.g. a PC connected to that; why would you expect them to work with something else?

I'm not familiar with the Mega, but it looks like you are using SoftwareSerial on hardware serial ports. Why not use Serial1?

And then the question is if you correctly wired the TX and RX lines between the Arduinos (19 to 18 and 18 to 19)?

If the first Mega uses this code to send the value

Serial.print('<');
Serial.print(potValue);
Serial.println('>');

then you can use the second third example in Serial Input Basics to receive the data and use the parse example to convert it back to an integer variable.

Unless there is a real need for performance it is much easier to debug communications that send data as human-readable characters.

...R
Edit to change "second" to "third" - apologies for any confusion

Why are you using SoftwareSerial on a Mega with 4 hardware serial ports?