Forum >Cherokey 4WD work with Wirless GamePad V2.0 (Xbee)
RoboticsGeneral

Cherokey 4WD work with Wirless GamePad V2.0 (Xbee)

userHead faweiz 2013-10-25 10:02:27 38671 Views49 Replies
Hello!

I've bought Cherokey 4WD with 2 Xbee and Wirless GamePad V2.0, where can I find any sketch to use this Wirless GamePad V2.0 with xbee to work with Cherokey 4WD?


I mean sketch for gamepad to control the Cherokey 4WD, not just the sketch to show the what button I pressed and show it on the serial minor.

Any help would be greatly appreciated!
2013-11-05 08:18:33 [quote="Grey"]
Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
[/quote]


Hi, grey,

I'm a afraid to say that I'm not using TEL0014, instead I'm using " XBee 1mW Chip Antenna (TEL0060 )". And I'm using "XBee USB Adapter V2" to connect two xbee to pc by using X-CTU software.

userHeadPic faweiz
2013-11-05 08:18:33 [quote="Grey"]
Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
[/quote]


Hi, grey,

I'm a afraid to say that I'm not using TEL0014, instead I'm using " XBee 1mW Chip Antenna (TEL0060 )". And I'm using "XBee USB Adapter V2" to connect two xbee to pc by using X-CTU software.

userHeadPic faweiz
2013-11-05 08:18:33 [quote="Grey"]
Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
[/quote]


Hi, grey,

I'm a afraid to say that I'm not using TEL0014, instead I'm using " XBee 1mW Chip Antenna (TEL0060 )". And I'm using "XBee USB Adapter V2" to connect two xbee to pc by using X-CTU software.

userHeadPic faweiz
2013-11-05 08:18:33 [quote="Grey"]
Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
[/quote]


Hi, grey,

I'm a afraid to say that I'm not using TEL0014, instead I'm using " XBee 1mW Chip Antenna (TEL0060 )". And I'm using "XBee USB Adapter V2" to connect two xbee to pc by using X-CTU software.

userHeadPic faweiz
2013-11-05 08:18:33 [quote="Grey"]
Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
[/quote]


Hi, grey,

I'm a afraid to say that I'm not using TEL0014, instead I'm using " XBee 1mW Chip Antenna (TEL0060 )". And I'm using "XBee USB Adapter V2" to connect two xbee to pc by using X-CTU software.

userHeadPic faweiz
2013-11-04 19:31:02 Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
userHeadPic Grey.CC
2013-11-04 19:31:02 Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
userHeadPic Grey.CC
2013-11-04 19:31:02 Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
userHeadPic Grey.CC
2013-11-04 19:31:02 Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
userHeadPic Grey.CC
2013-11-04 19:31:02 Hi Tony,
Could you provide your xbee link?Because different type of xbee has different setting.
Whether it is TEL0014?
If it was, that will be very easy.
Do you have a xbee usb adapter? And a software named"X-CTU" to set the parameter.[url=http://www.digi.com/support/productdetail?pid=3352]http://www.digi.com/support/productdetail?pid=3352[/url]
Here is a wiki about how to do.
[url=https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot]https://www.dfrobot.com/wiki/index.php/Xbee#Connecting_your_robot[/url]
userHeadPic Grey.CC
2013-11-02 22:05:47 [quote="Grey"]
Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?


[/quote]


Hello! Grey,

I'm using the "1mW XBee Transceiver Module (Trace Antenna)" and yes, I've already set the rate of xbees to 9600.

Please inform me if there is something I'm missing and I need to add.

Thank you!
Tony
userHeadPic faweiz
2013-11-02 22:05:47 [quote="Grey"]
Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?


[/quote]


Hello! Grey,

I'm using the "1mW XBee Transceiver Module (Trace Antenna)" and yes, I've already set the rate of xbees to 9600.

Please inform me if there is something I'm missing and I need to add.

Thank you!
Tony
userHeadPic faweiz
2013-11-02 22:05:47 [quote="Grey"]
Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?


[/quote]


Hello! Grey,

I'm using the "1mW XBee Transceiver Module (Trace Antenna)" and yes, I've already set the rate of xbees to 9600.

Please inform me if there is something I'm missing and I need to add.

Thank you!
Tony
userHeadPic faweiz
2013-11-02 22:05:47 [quote="Grey"]
Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?


[/quote]


Hello! Grey,

I'm using the "1mW XBee Transceiver Module (Trace Antenna)" and yes, I've already set the rate of xbees to 9600.

Please inform me if there is something I'm missing and I need to add.

Thank you!
Tony
userHeadPic faweiz
2013-11-02 22:05:47 [quote="Grey"]
Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?


[/quote]


Hello! Grey,

I'm using the "1mW XBee Transceiver Module (Trace Antenna)" and yes, I've already set the rate of xbees to 9600.

Please inform me if there is something I'm missing and I need to add.

Thank you!
Tony
userHeadPic faweiz
2013-11-01 20:06:51 Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?

userHeadPic Grey.CC
2013-11-01 20:06:51 Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?

userHeadPic Grey.CC
2013-11-01 20:06:51 Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?

userHeadPic Grey.CC
2013-11-01 20:06:51 Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?

userHeadPic Grey.CC
2013-11-01 20:06:51 Hi Tony
I think the receiver code has a little problem. It is no necessary to define the buttons for cherokey.
You know when you press buttons on gamepad, it will display the command in the Serial port.
And cherokey just receive the command,

For example , you define "up" as "6". When you press "up" , in the Serial port it shows "6".Then your cherokey receive "6" as command
Using "switch" command, when it receives "6" it will be set to move upward.
[code]int E1 = 5;    //M1 Speed Control
int E2 = 6;    //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void stop(void)                    //Stop
{
  digitalWrite(E1,0);
  digitalWrite(M1,LOW);   
  digitalWrite(E2,0); 
  digitalWrite(M2,LOW);   

void advance(char a,char b)          //Move forward
{
  analogWrite (E1,a);      //PWM Speed Control
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);

void back_off (char a,char b)          //Move backward
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW); 
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}
void turn_L (char a,char b)            //Turn Left
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);   
  analogWrite (E2,b);   
  digitalWrite(M2,HIGH);
}
void turn_R (char a,char b)            //Turn Right
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);   
  analogWrite (E2,b);   
  digitalWrite(M2,LOW);
}

void setup(void)
{
  int i;
  for(i=4;i<=7;i++)
    pinMode(i, OUTPUT); 
  Serial.begin(9600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW); 
  digitalWrite(E2,LOW);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
}

//String Buttons[17] = {
//  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
//  // Buttons Nmes

void loop(void)
{
  if(Serial.available()){
    //    String n = Buttons();
    char n=Serial.read();
      if(n != -1)
    {
      switch(n)
      {
      case '6'://Move Forward
        advance (255,255);  //move forward in max speed
        break;
      case '8'://Move Backward
        back_off (255,255);  //move back in max speed
        break;
      case '7'://Turn Left
        turn_L (100,100);       
        break;     
      case '9'://Turn Right
        turn_R (100,100);
        break;

      case '1':
        stop();
        break;
      }
    }
    else stop(); 
  }

}
[/code]

I just delete the "butten" it isn't a big issue.
but I think a good idea would be to start debugging the xbee configuration first.
What kind of xbee you are using now?
xbee S1/S2 ? or xbee for wifi? even bluetooth bee?
By the way whether you have an adapter to set xbee?

userHeadPic Grey.CC