[Help] Xbee - "Simple Example"

Hello. (I'm portuguese, I'm sorry for any gramatical or spelling mistake)

Basically, I'm asking for help because I can't make the Simple Example work...

Firstly, I'd like to say that I configured the XBee modules with the XBee Explorer (5 or 6 times actually). They have the same PAN ID and when powered, the Associate LED is blinking (End Device - 2/sec ; Coordinator - 1/sec).

I'm using two Arduinos, two Arduino Shields and two XBee Series 2.5 50mW (PRO).

I have the Coordinator AT attached to an Arduino with this code:

void setup()
{
  digitalWrite(13, HIGH);
  delay(3000);
  digitalWrite(13, LOW);
  Serial.begin(9600);
  Serial.println('X');
  delay(1000);
}

void loop()
{
  Serial.print('H');
  delay(1000);
  Serial.print('L');
  delay(1000);
}

And the Router/End Device AT in an Arduino with this code:

int outputPin = 13;
int val;

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

void loop()
{
  if (Serial.available()) {
    val = Serial.read();
    if (val == 'H') {
      digitalWrite(outputPin, HIGH);
    } 
    if (val == 'L') {
      digitalWrite(outputPin, LOW);
    }
  }
}

The Jumpers are on the XBee Position in both Shields.
The Associate LEDs keep blinking, but the 13Pin doesn't go HIGH on the End Device Arduino.

Am I missing something? Do you have some suggestions to make it work? Any help would be appreciated. :wink:

The only thing I see wrong with the code is a minor issue on the receiver.

int val;

should be

byte val;

Or "char val;" is okay too. The result of the Serial.read() is a single unsigned byte (0-255).

This change probably won't fix the problem though. I think you need to confirm that the characters are actually making it to and out of the router/end-point XBee. Do this by removing the ATmega chip from the receiving Arduino and then set the jumpers on the Xbee shield to "USB". Then connect the receiving end to your computer via USB use the serial monitor (set to 9600 baud) to confirm that you're receiving the "H" and "L" characters.