Problem with Communicating to Xbee.

I just got into wireless networking, and have purchased two xbees. Im trying to send a hex value of either 0x4 or 0x5 from the Coordinator in API mode, to turn on an LED on my other xbee. The book im using says to use :

example=Serial.print(0xFF, BYTE); to communicate with the other xbee to turn on a LED when a certain condition is met. But arduino says it no longer supports this, any suggestions?

I have the arduino hooked up to the coordinator btw and the non-coordinator hooked up to just a battery supply.

the code:

const int ledpin = 11;
const int debugpin = 13;
int analogvalue = 0;
int remoteindicator = false;
int lastremoteindicator = false;
unsigned long lastsent = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(ledpin,OUTPUT);
  pinMode(debugpin, OUTPUT);
}
void loop()
{
  if(Serial.available() >= 23) {
    if(Serial.read() == 0x7E) {
      digitalWrite(debugpin, HIGH);
      delay(10);
      digitalWrite(debugpin,LOW);
      for(int i =0; i<20; i++)
      {
        byte discard = Serial.read();
      }
      int analoghigh = Serial.read();
      int analoglow = Serial.read();
      analogvalue = analoglow + (analoghigh * 256);
    }
  }
  if (analogvalue > 0 && analogvalue <= 350)
  {
    digitalWrite(ledpin, LOW);
    remoteindicator = false;
  }
  if (analogvalue > 350 && analogvalue <=750)
  {
    digitalWrite(ledpin, HIGH);
    remoteindicator = true;
  }
  if(analogvalue > 750 && analogvalue <= 1023)
  {
    digitalWrite(ledpin,LOW);
    remoteindicator = false;
  }
  if(remoteindicator != lastremoteindicator)
  {
    if(remoteindicator == false) setremotestate(0x4);
    if(remoteindicator == true) setremotestate(0x5);
    lastremoteindicator = remoteindicator;
  }
  if(millis() - lastsent > 10000) {
    if(remoteindicator == false) setremotestate(0x4);
    if(remoteindicator == true) setremotestate(0x5);
    lastsent = millis();
  }
}

setremotestate(int value)
{
  Serial.print(0x7E, byte);
  Serial.print(0x0, byte);
  Serial.print(0x10, byte);
  Serial.print(0x17, byte);
  Serial.print(0x0, byte);
  Serial.print(0x0, byte);
  Serial.print(0x0, byte);
  Serial.print(0x0, byte);
  Serial.print(0x0, byte);
  Serial.print(0x0, byte);
  Serial.print(0x0, byte);
  Serial.print(0xFF, byte);
  Serial.print(0xFF, byte);
  Serial.print(0xFF, byte);
  Serial.print(0xFE, byte);
  Serial.print(0x02, byte);
  Serial.print('D', byte);
  Serial.print('1', byte);
  Serial.print(value, byte);
  long sum = 0x17 + 0xFF + 0xFF + 0xFE + 0x02 +'D' + '1'+value;
  Serial.print(0xFF - (sum& 0xFF, byte);
  delay(10);

Thanks

and have purchased two xbees

I won't bother with telling you what kind, how I configured them, or how I attached them.

Im trying to send a hex value of either 0x4 or 0x5 from the Coordinator in API mode, to turn on an LED on my other xbee.

Why? Send a packet containing 0x4 or 0x5, or send '4' or '5'. Which will be faster?

      int analoghigh = Serial.read();
      int analoglow = Serial.read();
      analogvalue = analoglow + (analoghigh * 256);

You are not sending analog values. Why do the names suggest that you are?

  if (analogvalue > 0 && analogvalue <= 350)

How does this relate to having sent 0x4 or 0x5?

One is configured in Coordinator API Mode and the other in AT Router/Command mode(I believe its called). Im taking readings from the AT Xbee using a photocell resistor, and if the readings are between a certain value, i.e. analogvalue. This will turn a light on at the Coordinators end that is hooked up yo the Arduino,but after the correct amout of light that the photocell picks up and turn the ledpin ON at the coordinators i want the arduino to send an AT Command to turn on the LED that i have attached to the AT xbee. So both xbee have a LED they need to turn on when the correct reading is being recieved.

So you can send a char as in Serial.print('4') instead of Serial.print(0x4)??And it'll mean the same thing?

So you can send a char as in Serial.print('4') instead of Serial.print(0x4)??And it'll mean the same thing?

Yes, you can, and no they won't. The character at position 4 in the ASCII table is not the '4'.

after reading the ascii chart if i wanted to send 0x0 i would have to send a Serial.print('NUL'). But i was wondering how i would need to send a 0x02. I cant seem to find this on the ascii chart.

techpec1:
after reading the ascii chart if i wanted to send 0x0 i would have to send a Serial.print('NUL'). But i was wondering how i would need to send a 0x02. I cant seem to find this on the ascii chart.

If you want to send a 0, send a 0, using Serial.write(). If you want to send a 2, do so. There IS an entry in the ASCII table at position 2.

No, Serial.print('NUL') is NOT how to send a 0. Single quotes are for single characters.

Ah ok, so I would use Serial.write(0) instead of Serial.print() to send API commands to the other xbee not hooked up to the arduino. Since Serial.print() converts it to a char depending on which type i use, like if I sent a 0x2A Id actullaly be sending a char value of *

Since Serial.print() converts it to a char depending on which type i use

NO IT DOES NOT! Serial.print() MAY convert what you send to AN ARRAY OF CHARS.

A char and an array of chars are NOT the same thing.

So what should I post, the says book says to Serial.print(0x7E, BYTE) but when i type this it says arduino doesnt support this format?

So what should I post, the says book says to Serial.print(0x7E, BYTE)

Read this sentence to your next door neighbor. What kinds of questions is he or she likely to ask? If you can anticipate the questions, and provide the answers, you'll have a LOT of time.

What book?

The print() method is for send ASCII data (data in text format). The write() method is for sending binary data. What does the BYTE value as the second argument suggest to you? What do the other Serial output statements in your code suggest to you?

To get 0x7E sent, use Serial.write(0x7E);.

but when i type this it says arduino doesnt support this format?

Is that a question! Or are you making a statement?