New Program to output Serial Data, from xbee to xbee.....

Hi

I am looking to take this program and use two Arduino's, two xbee's (Din and Dout). I only want to send the I/O High or low, to the other xbee. Using Serial Data. How do I go about this, and will it be easy, to change my program to do this.

So I want use Arduino and xbee to talk to the other Arduino and xbee, using serial Data.

So in the program I will have to change the (InPin, and the OutPin).

#define trigPin 12
#define echoPin 13
const int InPin = 3; 
#define OutPin 4
#define LedPin 5



int buttonState = 0;
void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
 
  pinMode(OutPin, OUTPUT);
  pinMode(LedPin, OUTPUT);
}

void loop() {
  buttonState = digitalRead(InPin);

  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance >= 200 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
  }
 
 if (distance < 10)
 {
   digitalWrite(OutPin, HIGH);
 }
 else 
 { 
 digitalWrite(OutPin, LOW);
 }
  if  (buttonState == HIGH && distance < 10) 
 {
        digitalWrite(LedPin, HIGH);
 }
         else
  {
       digitalWrite(LedPin, LOW);
  }
    delay(500);
}

I think the code has to start like this to work....

#define Rx    4			    // DOUT to pin 6
#define Tx    3			    // DIN to pin 7

#define trigPin 12
#define echoPin 13
 #define LedPin 5





SoftwareSerial Xbee (Rx, Tx);

void setup() {
  Serial.begin(9600);               // Set to No line ending;
  Xbee.begin(9600);		    //   type a char, then hit enter
  delay(500);
}

void loop() {
  buttonState = digitalRead(InPin);

  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance >= 200 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
  }
 
 if (distance < 10)
 {
   digitalWrite(OutPin, HIGH);
 }
 else 
 { 
 digitalWrite(OutPin, LOW);
 }
  if  (buttonState == HIGH && distance < 10) 
 {
        digitalWrite(LedPin, HIGH);
 }
         else
  {
       digitalWrite(LedPin, LOW);
  }
    delay(500);
}


  if(Serial.available()) {          
    char outgoing = Serial.read();  
    Xbee.print(outgoing);
  }
  
  if(Xbee.available()) {          
    char incoming = Xbee.read();   
    Serial.println(incoming);      
  }

  delay(50);
}