Xbee Pro XSC

We have been working on the xbee pro xsc for a couple of days,we got it to light the other arduino's led but were having problem display it on the com port,it continuously showed us -49 for any integer data.

the master code:

void setup() 
{
Serial.begin(9600); 
pinMode(2, HIGH);
Serial.print("start ");

}
void loop()
{
  
    Serial.print("0");
    delay(1200);
    
    Serial.print("1");
    delay(1200);
    Serial.print("2");
    delay(1200);
    Serial.print("3");
    delay(1200);
    Serial.print("e");
    delay(1200);
    Serial.print("f");
    delay(1200);
    
  
}

the slave code:

int led = 13;


void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  Serial.print("start on slave");
}
void loop()
{
  
if (Serial.available() > 0)
{
  if (Serial.read() == '0')
  {int data=Serial.read();
  data=data-'0';
  Serial.print(data,DEC);
    digitalWrite(13,HIGH);
  }
else
{
  digitalWrite(13,LOW);
}
}
}

Your pinMode(2,HIGH) in your master code should not be HIGH, it should be either OUTPUT or INPUT. Im surprised you didn't get an error message. Also your trying to SEND a CHAR not an INT, so your slave code should not be looking for an INT, it should be:
char data = Serial.read();
And for your master code should be:
Serial.Write('0');
Serial.Write('1');
Serial.Write('2');
Serial.Write('3');
etc

Serial.print("0") should not be used here

sorry but we are not even using the pushbutton...so therefore the display is only being produced by the arduino.

ok, regardless if your using a button or not, if you want to send data from the master to the slave you need to Serial.Write it otherwise the slave will get the wrong data.

also that -49 is just (-'0'), there is no incoming data so data = data-'0'; is going to produce -49 everytime.

ok so this is the new output on 0 and 1 after tweaking:
start on slaveÏÏ

Also one other thing, if you want to receive data from the master to the slave and then print that data from the slave, you need to have a ARD mega, because a regular UNO will not be able to do both.

Unless, your master has a LCD display in which case it can do both, but to get the data from a RF or BT module and then display it on a computer monitor, it can't do that.

MEGA:
Serial.begin(9600); //print the incoming data to the screenget the incoming data
Serial1.begin(9600); // get the incoming data

Serial.print(/your data here/); // NOTICE the Serial"1" this puts your data on a different TX/RX to be output to the screen.

ok so we made the master as the mega now and the uno as the slave,and changed it to Serial1.write();

no the slave has to be the MEGA, because it is doing two different things with its TX and RX ports.

oh I edited my previous comment, I change the Serial and Serial1 lines. Serial is connected the usb so that should go to the PC monitor.

and doesnt the mega have 4 serial ports,im using the 0th one,so do i need to configure it as 1

no RX0 and TX0 is just Serial, everything else is Serial1...2...3.

yup so ive put it at tx0 and rx0 so i didnt configure it

As of right now, does it work? Also I think the Xbee needs to be off inorder to upload the code properly.

What are the error messages, if any?

yup that is happening,the thing is that its glowing the led whenever defined like at 0 or 1,it does go on and the rest of the times its off,but the problem is with receiving the data,its showing me values that are constant

I'm an idiot for not asking this before, do you know how to use an xbee or is this your first time?
If this is your first time, then please go on youtube and find some tutorials. I have a sample code here that may help you.

Also watch this guy:

The Xbee has it's own way of communicating to the arduino. It will not accept Serial.read or write commands, instead it has its own xbee.read and xbee.write.

HOWEVER...

If you just want to test the code you wrote, use jumper cables to simulate a connection.

Master ARD: Slave ARD
TX =======> RX
RX =======> TX

And for your slave code, just do this:

int led = 13;


void setup()
{
  Serial.begin(9600);    // usb connection to PC, view in ARD serial monitor
  Serial1.begin(9600);  //connect to mega
  pinMode(led,OUTPUT);
  Serial.println("start on slave");
}
void loop()
{
  
if (Serial1.available() > 0) {
         digitalWrite(led,HIGH);
         char data=Serial1.read();
         Serial.print(data); 
         data = ' '; // clears data for new char, (just in case)
}
else {
         digitalWrite(led,LOW);
       }
}

its actually not the first time,ive configured it,and ive seen that video too but it doesnt help alot as ive a xbee pro xsc,but the connection is established and im using a 3v3 regulator to connect to the arduino for both my xbees,
dout=rx0(data that came ,now stored in the buffer)
din =tx0(data coming in from the arduino to transmit)
and the thing is all the codes that Ive tried till now can only do a specific function like light an led,or like jeremy blum's servo motor,but i still dont know to receive data.
The major problem with this xbee in specific is that it cant go more than 9600 baud rate,plus it works on point to point communication,so i really cant use the api mode.

ok then dont use Xbee, use Bluetooth or RF transceivers, they are SO much easier.

The major problem with this xbee in specific is that it cant go more than 9600 baud rate,plus it works on point to point communication,so i really cant use the api mode.

yes it can go beyond 9600 if you know how to do it. And I apologize, it can use Serial.read and write.

now from the codes you wrote, what do you want to actually do with it?

Also try that jumper trick I said before, so you can see what the slave ARD is actually getting.

check out this, if you have not already:

yeah i think thats what im going to do next,its taken too long,the main function for this was long range thats why i bought it,and its taken me so long to get it to work.What xbees did you use?

The series 1 xbees.

quick question, did you follow that video from sciguy completely? Because he shows what program to download and how to setup the xbees. Im just curious, thats all.

yup,for this xbee,basically instead of choosing the xbee model like xb 24 or something and then choosing router at or coordinator at,i had to choose xbee xsc 9600 which automatically comes when its read,now comes the fun part,i cant use atdh or atdl for this,so it took me along time figuring this out ,the two commands are ATID(pan address) which i set as default for both,and ATDT which have to be the same so i put it as 0100 using teraterm instead of putty ,and the communication was made after ATWR.
And the thing is that it isnt series 1 or series 2 or pro versions of those 2,there is a totally different model XBee Pro 900 XSC RPSMA - WRL-09087 - SparkFun Electronics