Now I tried to use this code with my XBee 2 series and it doesn't work. I know that setting of the Xbee are correct because when I use different simple code , it works. So basically, no XBee setting problem at all.

Anybody have any idea why this code doesn't work with XBee 2 and any solution? Will it work with XBee 1(that I don't have)?

I wanted to use XBee for my project but the code I know is not stable. Project is simple to control the LED at the other side. The code in the "Wireless Sensor Networks" and "Arduino Cookbook" are simple and not stable. Anybody have more robust code to control a LED like the one shown in the link.

You need to modify the code to use xbee. You also need to configure the modules, have you done that? The Adafruit series1 modules are different than the series2 so code found here might not work in your case.

Thanks franklin for your comments.As I said earlier, I have configure the module and it is correct that it works with different code.To modify the code to use xbee, I cannot find the code to modify based on my knowledge. Because both module (RF & xbee) do not need any library and use serial port to transmit/receive data.When I use simple code to test, both are working. But not this code.If anybody found the solution, please let me know.

franklinThe code I have tried is simple and works. those are from the book I mentioned earlier.However transmitted data lost in transit sometime. Therefore data exchange is not reliable.But the code in the link is relatively more reliable. Unfortunately it doesn't work with xbee 2.

You shouldn't be losing data at all, especially with XBees that are paired together properly, at a reasonable range from each other and with a clean power source (the Arudino's 3.3 output pin should be pretty clean.

Try the code in Building Wireless Sensor Networks for the Doorbell project. It is extremely simple and relies on the XBee's transparent mode to behave essentially like a serial cable connection. Also check your radios in X-CTU to make sure that you have the latest version of the firmware. Your Series 2 might have shipped with a very early version and a lot of improvements have been made that you'll certainly want to have.