I am trying to make two arduino to communicate using Xbee's but when I send numbers the arduino converts them to ascii characters, for example if I type 42 on the serial monitor it transmits *, how can I change that? This is the code that I am using.
#include <SoftwareSerial.h>
#define Rx 0 // DOUT to pin 6
#define Tx 1 // DIN to pin 7
SoftwareSerial Xbee (Rx, Tx);
void setup() {
Serial.begin(57600); // Set to No line ending;
Xbee.begin(57600); // type a char, then hit enter
delay(100);
}
void loop() {
if(Serial.available()) { // Is serial data available?
char outgoing = Serial.read(); // Read character, send to XBee
Xbee.print(outgoing);
}
if(Xbee.available()) { // Is data available from XBee?
char incoming = Xbee.read(); // Read character,
Serial.println(incoming); // send to Serial Monitor
}
delay(50);
This is my first time using xbee's, dont I have to use pins 0 and 1 to transmit and receive? this was an example that I found on the internet and I was trying to understand it
You can NOT effectively use the hardware serial pins to talk to the XBee and the PC. If you don't mind crosstalk, then just use Serial to talk to both. Doing so will get very confusing.