Go Down

Topic: Xbee Serial Communication (Read 372 times) previous topic - next topic

hes50

I have two Xbees, each connected to an Arduino Uno. The problem is that whenever I switch the sender on, the receiver is receiving "224" (or if I used a char variable, "à") no matter what the sender is printing.

Receiver code:

Quote

void setup () {
  Serial.begin(57600);
  Serial.println("Ready1");
pinMode (8,OUTPUT);


  void loop () {
    while(Serial.available()){
      B = Serial.read();
   
    Serial.print(B);
    }
  B=0;
   
    if (B==224){
      digitalWrite (8,HIGH);
     
      delay(1);
    }
   
    else
    digitalWrite (8,LOW);
   
  }


Sender code:

Quote

void setup()
{
  Serial.begin(57600);}
  void loop (){
    Serial.print("A");
    delay (1);
  }

The receiver code doesn't compile. Please post code that compiles. And put it in code tags.

You can do that by hitting the # button above the posting area.

Code: [Select]
sketch_apr27c.cpp: In function 'void setup()':
sketch_apr27c:6: error: a function-definition is not allowed here before '{' token
sketch_apr27c:23: error: expected `}' at end of input
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

PaulS

Code: [Select]
  B=0;
   
    if (B==224){

How would that if test ever be true?

Go Up