Arduino Forum

Topics => Robotics => Topic started by: aman25 on Jun 24, 2015, 08:38 am

Title: xbee wireless communication using joystick
Post by: aman25 on Jun 24, 2015, 08:38 am
code at receiver side .


#include<EasyTransfer.h>
//#include<Wire.h>

int a1=2;
int a2=3;
int b1=4;
int b2=5;
int jack=6;
int m;
int n;






EasyTransfer lt;

typedef struct RECEIVE_DATA_STRUCTURE
{

int x;
int y;
int z;
};
RECEIVE_DATA_STRUCTURE aman;
//#define  I2C_SLAVE_ADDRESS 9

void setup(){
//Wire.begin(I2C_SLAVE_ADDRESS);
lt.begin(details(aman),&Serial);
//Wire.onreceieve
Serial.begin(9600);
pinMode(a1,OUTPUT);
pinMode(a2,OUTPUT);
pinMode(b1, OUTPUT);
pinMode(b2,OUTPUT);
pinMode(jack,OUTPUT);

}

void loop()
{
if(lt.receiveData())




m=map(m,0,1023,-1,1);
n=map(n,0,1023,-1,1);

if(m==0 && n==0)
{
digitalWrite(a1,LOW);
digitalWrite(a2,LOW);
digitalWrite(b1,LOW);
digitalWrite(b2,LOW);
}

else if(m==0 && n==1)
{
digitalWrite(a1,HIGH);
digitalWrite(b1,LOW);
digitalWrite(a2,HIGH);
digitalWrite(b2,LOW);

}
else if(m==0 && n==-1)
{
digitalWrite(b1,HIGH);
digitalWrite(a1,LOW);
digitalWrite(b2,HIGH);
digitalWrite(a2,LOW);

}
else if(m==1 && n==0)
{
digitalWrite(a1,LOW);
digitalWrite(b1,LOW);
digitalWrite(a2,HIGH);
digitalWrite(b2,LOW);

}


else if(m==-1 && n==0)
{
digitalWrite(a1,HIGH);
digitalWrite(b1,LOW);
digitalWrite(a2,LOW);
digitalWrite(b2,LOW);

}


}



this is my arduino code for receiver side and i am using xbee for wireless communication , but the problem is i am not able to get the output  on other side . plz help me .


code at transmitter side

#include<EasyTransfer.h>

int vx=A0;
int vy=A1;
int cam=8;
EasyTransfer lt;


struct SEND_DATA_STRUCTURE
{
int x;
int y;
int z;
};

SEND_DATA_STRUCTURE aman;

void setup()
{
pinMode(cam,INPUT);
Serial.begin(9600);
Serial.begin(9600);
lt.begin(details(aman),&Serial);


}
void loop()
{
aman.x=analogRead(vx);
aman.y=analogRead(vy);
aman.z=digitalRead(cam);
lt.sendData();

}
Title: Re: xbee wireless communication using joystick
Post by: Isaac96 on Jun 27, 2015, 04:59 am
Try something like the SoftwareSerial examples first to make sure the XBee's are working.
Title: Re: xbee wireless communication using joystick
Post by: shubhsa on Jun 27, 2015, 02:46 pm
yes i have tested my xbee and its  working properly ,  the problem i am facing is of my code can you tell me that my code is right .
Title: Re: xbee wireless communication using joystick
Post by: zoomkat on Jun 27, 2015, 08:27 pm
Quote
can you tell me that my code is right .
#7 below:

http://forum.arduino.cc/index.php/topic,148850.0.html (http://forum.arduino.cc/index.php/topic,148850.0.html)
Title: Re: xbee wireless communication using joystick
Post by: zoomkat on Jun 27, 2015, 08:32 pm
Similar discussion.

http://forum.arduino.cc/index.php?topic=332395.msg2293355#msg2293355 (http://forum.arduino.cc/index.php?topic=332395.msg2293355#msg2293355)
Title: Re: xbee wireless communication using joystick
Post by: aman25 on Jun 28, 2015, 07:04 am
thanxx for the help sir , but i am working with dc motors, joystick and xbees . and the link you have given me is of servo and pot .
sir it would be great help if  you can help with code which i have posted earlier in this thread .
Title: Re: xbee wireless communication using joystick
Post by: Isaac96 on Jun 28, 2015, 06:26 pm
Joysticks are just pots. And it is easy to convert servo commands to DC motor commands.
Title: Re: xbee wireless communication using joystick
Post by: aman25 on Jun 29, 2015, 08:21 pm
sir can you tell me the mode in which xbee should be configured , i mean which xbee as coordinator and which to router.
Title: Re: xbee wireless communication using joystick
Post by: Isaac96 on Jun 30, 2015, 04:45 pm
Transparent is great for XBees. They just take data and send it.
Title: Re: xbee wireless communication using joystick
Post by: aman25 on Jul 01, 2015, 11:28 am
the problem i am facing is that the din light of one xbee is continuously blinking but in other xbee only rssi and power lights   are on . i dont know how to overcome this problem . plz help me out .
Title: Re: xbee wireless communication using joystick
Post by: Isaac96 on Jul 01, 2015, 05:06 pm
Have you used X-CTU to configure your XBees?
Title: Re: xbee wireless communication using joystick
Post by: aman25 on Jul 04, 2015, 01:54 pm
yes sir i have used x-ctu to configure xbee but the xbees are not transmitting the data . plz help sir
Title: Re: xbee wireless communication using joystick
Post by: Isaac96 on Jul 04, 2015, 04:48 pm
Do you have the right baud rate?
EDIT See http://cpham.perso.univ-pau.fr/WSN/XBee.html (http://cpham.perso.univ-pau.fr/WSN/XBee.html)
Title: Re: xbee wireless communication using joystick
Post by: andyibanez on Jul 05, 2015, 07:23 pm
Better to use #softwareserial
Use 10 for Rx and 11 for Tx
U must try communicate between xbee with 2 xbee explorer first


Use software serial library,
Myserial.println(data);
Title: Re: xbee wireless communication using joystick
Post by: aman25 on Jul 06, 2015, 03:12 pm
sir both the xbees are communicating in there terminal but when any signal is given from joystick they are transmitting data . plz help sir