xbee + arduino data transfer problem

Bluetooth, XBee, RF......

xbee + arduino data transfer problem

Postby nuffy » Fri Apr 12, 2013 12:41 am

i have this problem, sometimes my arduino process the data but some times it ignore the data received from xbee.

the function is just simple. from my pc via x-ctu i send " 1" and xbee 1 transmit to xbee 2.. xbee2 is connected to arduino and light up led .
im just wondering why this happen?
here is my programm :
CODE: SELECT_ALL_CODE
int myData = 0;
int const ledpin = 13;
#include <SoftwareSerial.h>

SoftwareSerial mySerial (11,12);

void setup(){
  Serial.begin(9600);
  mySerial.begin (9600);
  pinMode(ledpin, OUTPUT);
}

void loop(){
  {
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}
  if(Serial.available() > 0){
   
    myData = Serial.read();
   
    if(myData =='1'){
      digitalWrite(ledpin, HIGH);
      Serial.print(myData);
    }
   
    if(myData == '2'){
      digitalWrite(ledpin, LOW);
      Serial.print(myData);
    }
    else{
      Serial.print(myData);
    }
  }
}
nuffy
Greenhorn
 
Posts: 3
Joined: Fri Apr 12, 2013 12:02 am

Return to Wireless Device

Who is online

Users browsing this forum: No registered users and 14 guests

cron