P2P communication with Xbee series 2

Thanks for your answer.

It's still like before however: the servo occasionaly moves, randomly (more like jiggles), but doesn't respond to the potentiometer input. Just in case, here are the source codes (i made some minor changes on the original code).

Potentiometer:

//Define Pins
int potPin = 5;

void setup()
{
  //Create Serial Object (9600 Baud)
  Serial.begin(9600);
}

void loop()
{
  int val = map(analogRead(potPin), 0, 1023, 0, 180);
  Serial.println(val);
  delay(50);
  
}

Motor:

//Include Servo Library
#include <Servo.h>

//Define Pins
int servoPin = 9;

//Create Servo Object
Servo jeremysServo;

void setup()
{
 //Start Serial
 Serial.begin(9600);
  
  //Attaches the Servo to our object
  jeremysServo.attach(servoPin);
  
  delay(500);
}

void loop()
{  

  while( Serial.available() == 0);
  int data = Serial.read() -'5';

  int pos = map(data, 0, 1023, 0, 180);

  //Turn the servo
  Serial.println(pos);
  jeremysServo.write(pos);
  Serial.flush();  
    
}