2 Xbee S1 and 2 ArduinoMema - Communication problem.

Hello everyone , i configure my both Xbee S1 and wrote a simply programm where when i send "12" via X-TCU i turn off a LED on my arduino. I send with X-TCU terminal the "0C" hex value and the LED is turn off. So seems i set correct the Xbee.

Now when i try to communicate Arduino-Xbee --> Arduino-Xbee seems like nothing is working :confused:
Thats the 2 programms

Send program:

//int const ledpin = 13;
void setup()
{
  //pinMode(ledpin, OUTPUT);
 Serial.begin(9600);
}

void loop()
{
 delay(3000);           //delay 3sec
 int val = 12;               
 Serial.print(val);     // send 12
 for(;;) ;  //stay here
}

And recieve programm:

int const ledpin = 13;

void setup()
{
  pinMode(ledpin, OUTPUT);
 Serial.begin(9600);
 digitalWrite(ledpin, HIGH);
}

void loop()
{
  
    if(Serial.available() > 0)
    {
      
        int myData = Serial.read();
        
        if(myData == 12)
        {
        digitalWrite(ledpin, LOW);
         }
      }
}

LED on recieve programm its always ON, like the dont get the value or get it wrong.

I'll be pleased if someone can help

i configure my both Xbee S1

How? Didn't you think that might be important?

 int val = 12;               
 Serial.print(val);     // send 12

No, it, doesn't. It sends "12". Not the same thing AT ALL.

        int myData = Serial.read();

Serial.read() returns an int, so it can tell you if there was nothing to read. Since you already check that, you should save the byte you read into a byte variable.

        if(myData == 12)

You didn't send the value 12, so you can't expect to read the value 12.

Serial.write() on the sender would send the low order byte as a binary value, which is what you are expecting to read.

Yeah problem Solved. I had to clear on my mind the serial.print and serial.write

Check this tutorial too. They have interfaced Arduino with XBee Module and also provided the code for it so I think it will help you out.