Hi,
May I use SoftwareSerial on Arduino Uno R3? And what pins can I use for SoftwareSerial?
Regards
Hi,
May I use SoftwareSerial on Arduino Uno R3? And what pins can I use for SoftwareSerial?
Regards
Yes you can use software serial on a Uno. As far as I know, any digital pin can be used, but I would not use pins 0 or 1 as they are the hardware serial pins.
May I use SoftwareSerial on Arduino Uno R3?
Please feel free to go ahead. Sorry, I couldn't resist.
And what pins can I use for SoftwareSerial?
http://arduino.cc/en/Reference/SoftwareSerial mentions no restrictions for the Uno apart from the fact that the pins used should be digital.
Thank you.
I asked this because I'm trying to use XBee, but it's not working. So the problem should be another.
I'm using digital ports 10 and 11 for Serial communication with XBee.
Regards.
If you provide more info we may be able to help. Post your code and a description of your setup. A picture, please not huge (1024x768 is plenty), or a schematic would help.
It worked. I think that the problem were in hardware, because it has worked for a few seconds. I have measured the voltage on DIN and DOUT pins of XBee and them hadn't power.
However I'm going to post here my code.
Sender Code:
#include <XBee.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
XBee xbee = XBee();
uint8_t send_buffer[2];
XBeeAddress64 addr64 = XBeeAddress64(0x00000000, 0x0000ffff);
ZBTxRequest zbTx;
void setup() {
send_buffer[0] = 1;
send_buffer[1] = 2;
zbTx = ZBTxRequest(addr64, send_buffer, 2);
Serial.begin(9600);
mySerial.begin(9600);
xbee.setSerial(mySerial);
}
void loop() {
Serial.println("Interacao");
xbee.send(zbTx);
delay(1000);
}
Receiver code:
#include <XBee.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
ModemStatusResponse msr = ModemStatusResponse();
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
xbee.begin(mySerial);
}
void loop() {
Serial.println("Iteracao");
xbee.readPacket(1000);
if(xbee.getResponse().isAvailable()){
Serial.println("Resposta disponivel");
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
xbee.getResponse().getZBRxResponse(rx);
for(int i=0; i < rx.getDataLength(); i++)
Serial.println(rx.getData(i));
}
}
}
XBeeAddress64 addr64 = XBeeAddress64(0x00000000, 0x0000ffff);
The whole reason for using the XBee library is to have two Series 2 radios talk specifically to each other. Putting one in broadcast mode and one into listen-to-everyone defeats that purpose. Why are you doing that?
XBee xbee = XBee();
Wrong!
XBee xbee;
Right!