WHATS THE PROBLEM OCIFFER!

int incomingByte = 0;

void setup(){
  Serial.begin(9600);
  delay(500);
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop(){
  sendbyte();
  getbyte();
}

void sendbyte(){
  Serial.println("1");
  delay(500);
  Serial.println("2");
  delay(500);
}


void getbyte(){
  if (Serial.available() > 0){    
    incomingByte = Serial.read();
    delay(500);
  } 
  else if(incomingByte == 1) {
    digitalWrite(13, HIGH);
  } 
  else if (incomingByte == 2){
    digitalWrite(13, LOW);
  }  
}

That is the code i use for my two xbee's on two arduino duemilanove. The two xbees have different breakout boards one from adafruit and other from sparkfun. I set the baud rates and pan id's the same and an led on both to help debug. But i have yet to see results that work. None of the led's blink. :cry:

I'll leave it to the programming guys to give you the details, but in the meantime, it looks to me as though the if's and elseifs in getbyte() are all over the place.

int incomingByte = 0;

void setup(){
  Serial.begin(9600);
  delay(500);
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop(){
  sendbyte();
  getbyte();
}

void sendbyte(){
  Serial.[glow]print[/glow]("1");
  delay(500);
  Serial.[glow]print[/glow]("2");
  delay(500);
}


void getbyte(){
  if (Serial.available() > 0){
    incomingByte = Serial.read();
    delay(500);
  }
  if(incomingByte == [glow]'1'[/glow]) {
    digitalWrite(13, HIGH);
  }
  if (incomingByte == [glow]'2'[/glow]){
    digitalWrite(13, LOW);
  }
}

For starters.. I haven't played much with receiving serial yet, but when you send with "println()", it also send a carriage return at the end (2 bytes total in your example). It probably still works with "println()" though.
Also: Arduino Reference - Arduino Reference

if (Serial.available() > 0){
    incomingByte = Serial.read();
    delay(500);
  }
  else if(incomingByte == 1) {

If you haven't read anything, why are you at all interested in the previous value read?

The "if" is waiting till i get a value read then it proceeds to the next "if", so it can check an see if its a "one" or a "two."

If there isn't anything to read, you're looking at the last value you assigned to "incomingByte".
Did you mean to write :

if (Serial.available() > 0){
    incomingByte = Serial.read();
    delay(500);
     if(incomingByte == 1) {
 }

?

( not sure what the half second delay is for)

I assigned it zero because that part of the code only moves on if its greater than zero. And write it what?

I assigned it zero

What is "it", and where is "it" assigned zero?

Did you mean here:
int incomingByte = 0;?

There was no need to assign it zero, it would be automatically be assigned zero before "main" ran.

I still don't understand this:

if (Serial.available() > 0){
    incomingByte = Serial.read();
    delay(500);
  }
  else if(incomingByte == 1) {
    digitalWrite(13, HIGH);
  }
  else if (incomingByte == 2){
    digitalWrite(13, LOW);
  }

construct.
Can you explain what you expect it to do?

Well yes i assigned it zero to declare the variable. And the function "getbyte", is ment to read the serial line then if it is a one or a two it will either switch the led assigned to pin 13 on or off, depending on the variable.

And the function "getbyte", is ment to read the serial line then if it is a one or a two

But it doesn't do that - check your braces and your elses.

i assigned it zero to declare the variable

There's no need to assign anything to it to declare it.
If you want to assign anything other than zero (which is assigned to all global scope varaibles) then assign that value.

One thing is because you send a ascii 1 and not a decimal 1, try replacing 1 and 2 by '1' and '2', including the '', as that make the arduino IDE see that you want to compare the numbers 1 and 2 and not the ascci code 1 and 2.

Also can it be the hardware?

No

Well maybe. If you've wired it up wrong, but please, sort the software first :slight_smile:

i have revised the software. But their is still no response!

Then post your revised code?