Go Down

Topic: Xbee Serial Communication (Read 400 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);
  }

Nick Gammon

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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy