Go Down

Topic: xbee wireless communication using joystick  (Read 1 time) previous topic - next topic

aman25

Jun 24, 2015, 08:38 am Last Edit: Jul 11, 2015, 01:48 pm by aman25
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();

}

Isaac96

Try something like the SoftwareSerial examples first to make sure the XBee's are working.
Do not PM me for help. I will delete immediately.
CONNECT THE GROUNDS!

After Tuesday, even the calendar goes W T F

shubhsa

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 .

zoomkat

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

zoomkat

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

aman25

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 .

Isaac96

Joysticks are just pots. And it is easy to convert servo commands to DC motor commands.
Do not PM me for help. I will delete immediately.
CONNECT THE GROUNDS!

After Tuesday, even the calendar goes W T F

aman25

sir can you tell me the mode in which xbee should be configured , i mean which xbee as coordinator and which to router.

Isaac96

Transparent is great for XBees. They just take data and send it.
Do not PM me for help. I will delete immediately.
CONNECT THE GROUNDS!

After Tuesday, even the calendar goes W T F

aman25

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 .

Isaac96

Have you used X-CTU to configure your XBees?
Do not PM me for help. I will delete immediately.
CONNECT THE GROUNDS!

After Tuesday, even the calendar goes W T F

aman25

yes sir i have used x-ctu to configure xbee but the xbees are not transmitting the data . plz help sir

Isaac96

#12
Jul 04, 2015, 04:48 pm Last Edit: Jul 04, 2015, 04:51 pm by Isaac96
Do you have the right baud rate?
EDIT See http://cpham.perso.univ-pau.fr/WSN/XBee.html
Do not PM me for help. I will delete immediately.
CONNECT THE GROUNDS!

After Tuesday, even the calendar goes W T F

andyibanez

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);

aman25

sir both the xbees are communicating in there terminal but when any signal is given from joystick they are transmitting data . plz help sir

Go Up