I am trying to interface XBee device with the arduino UNO. I am unable to figure out how to use the XBEE.h library. I tried tried examples but those are not working.
Any ideas how to come up with a code at the transmitter and receiver side ?
This is is the code I have tried at the receiver side. Sender side I have used XCTU software for sending the packet. Used softwareserial library.
'#include<SoftwareSerial.h>
SoftwareSerial softwareserial(4,5); // 4 -> TX, 5 -> RX
#define led 13
uint8_t myaddress[10];
int i = 0;
byte data;
byte discard;
void setup()
{
Serial.begin(9600);
softwareserial.begin(9600);
pinMode(led,OUTPUT);
}
void loop()
{
int a[15];
if(softwareserial.available()>14)
{
if(softwareserial.read() == 126)
{
for(i=0;i<14;i++)
{
discard = softwareserial.read();
Serial.print(discard,HEX);
Serial.print(" ");
}
if(softwareserial.read()==31)
{
data = softwareserial.read();
Serial.print((char)data);
}
if(data == '1')
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
Serial.println(" ");
}
}
}`