Pages: [1]   Go Down
Author Topic: Xbee Serial Communication  (Read 354 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
  }
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50928
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  B=0;
   
    if (B==224){
How would that if test ever be true?
Logged

Pages: [1]   Go Up
Jump to: