Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I have an Arduino Uno with a Wireless SD Shield and XBee S1 and a PC with another XBee S1 connected to it. What I'm after is for me to be able to send a message from my computer and receive a message back from the Arduino (For now let's just say if the Arduino receives a "1" I want it to send an "A" back) Here is the code I have been practicing with (courtesy of SparkFun)

#include <SoftwareSerial.h>
SoftwareSerial XBee(0, 1); // RX, TX

void setup()
{

XBee.begin(9600);
Serial.begin(9600);
}

void loop()
{
if (Serial.available())
{ 
XBee.write(Serial.read());
}
if (XBee.available())
{ 
Serial.write(XBee.read());
}
}

(I have changed the pins from 2,3 to 0,1 as the latter is on the Arduino itself) I have set my Xbees up and have been able to get them to talk to each other when both connected to separate PC's, but I am having trouble getting the Arduino to send information to the other XBee. When I try and send data from the Arduino IDE both RX and TX Led's flash. Could anyone steer me in the right direction? Many Thanks,

share|improve this question

1 Answer 1

You don't need to declare an extra (software) serial port because the wireless shield connects the Arduino TX and RX on pins 0 and 1 directly to the TX and RX of the Xbee. So, Serial.available, Serial.read and Serial.write directly addresses the xbee. Just leave out the software serial from your code and it should work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.