XCTU + XBEE + Mega(1280) + SPARKFUN SHIELD W/Explorer.

I have some code written/copied and modified it so far based upon what i have learned so far. I am using Arduion IDE 1.0.1. I am trying to get one (for now) DC motor to turn on then off using XCTU with this snippet of code. The whole code turns the motor left (on) when i press 'a' and stays on until i press right 'd' and the motor turns the other direction. Nice :) but would like to have the xctu to recognize that i am no longer pressing the 'a' or the 'd' key. I have put a delay in there but i only want the motors to turn only if i am pressing the keys on the keyboard. Is there a function to implement in the code or is it due to xctu and the way it works. My hobby project is to control two dc motors using xbee series 1 retail kit from sparkfun, motor shield from seeedstudio, and freeduino for the robot and i have the usb xbee explorer connected to xctu on my laptop. Here is the code snippet that turns the motors .. I am not a student and i am not totally new, but new enough. I have picked this up about two years ago as a hobby and haven't looked back, hence the expensive taste in xbee that I purchased from sparkfun a week ago. Thanks for you productive and informative replies. I too wish to learn not to be told how to do it out right but can you nudge me in the right direction especially if it is staring at me in the face. Thanks.

  Void loop()
{
if(Serial.available()>0
{
byte info=Serial.read();
Serial.println(info);

if(info=='a'){
left();

}
else if(info=='d'){
right();
}

sort of the same code for forward and backward with an end of } } delay(20); }

but would like to have the xctu to recognize that i am no longer pressing the ‘a’ or the ‘d’ key.

Then, you should be asking over at digi.com, for them to revise the X-CTU program. Don’t hold your breath.

You can write your own application that does something when you press, and when you release, a key.

but would like to have the xctu to recognize that i am no longer pressing the 'a' or the 'd' key

On the serial port? That doesn't send key-down/key-up messages. If you attach your own keypad you could detect that sort of stuff. Or as PaulS says, have one key for start, and another for stop.

Nick and Paul,

Darn, thought there was something that I was missing in my code here on my side. I guess the external keypad/joystick is the only way to go, unless there is an alternative program (maybe arduino processing)????.even then the keys press depress may not work either. Holding my breath is easy, i asked the right questions and you understood, for that gentlemen, I say send a huge thank you! Now that i am faced with using xbee on a bread board or perhaps soldering extra pins to the explorer for breadboard application, i would expect that there would be no additional parameters to be set since both xbee's are in sync with each other ""right?"" The most i could do now would be to use two arduino's one with shield, the other on the breadboard since i don't have two shields.""Right"".. No problem here :roll_eyes:, just another hill to climb and conquer.

I do have another question! I am thinking the joystick would be a nice touch but bulky to tote around. What would be my best option, a purchased Parallax 27800 2-Axis Joystick or hacking my own saitek usb joystick with rs232 breakout(shich i do have) from sparkfun? I am also thinking that i would need the rs232 for the explorer anyway since it is usb too... I do have roborealm software which does already use the saitek joystick but i am not sure how to get the xbee to send the commands using the roborealm. If anyone could "enlighten" me on using roborealm with xbee that would be soooo greatful. Any thoughts or what if's are greatly appreciated.

Thanks PualS and Nick Gammon, Techdetect.

GOOD NEWS :sweat_smile:, Got the xbee + XCTU + seeedstudio motor shield + Xbee shield with explorer to work. It controls two dc motors using XCTU. Yeah, the key release still doesn't work but i have added a stop key so if i want it to stop it will. I feel on cloud 8 right now, only 8 because i am trying another project to work with roborealm and i need VBscript experience. But, I set that aside to work on this remote controlled robot till I get a few answers. UMMM wondering if i should have kept the remote control and saved me a few bucks, but knowledge is priceless.... ]:D

For those who would like to see the code or the aka robot (very roughly built) just give a shout out.

And for those trying to get thier bees working, I bought them paired already :D

About the robot, simple two dc motors, goes forward, reverse, right, left. Can easily be adapted for servos too.(or at least I think)

Go Arduino

Hi

i also want to do the same thing, currently i am able to do this without the help of an xbee, but since i am looking for a wireless control of the robot
eg: ‘w’ moves forward
‘a’ moves left
‘d’ moves right
‘x’ moves back
‘s’ stops
i am posting the code for controlling it on the arduino, but i am not sure as to how i should split this code for the receiver and the sender ends

could anyone please help :disappointed_relieved:

thanks

int EN1 = 6;  
int EN2 = 5;  //Roboduino Motor shield uses Pin 9
int IN1 = 7;
int IN2 = 4; //Latest version use pin 4 instead of pin 8
  
 
 
void Motor1(int pwm, boolean reverse)
        {
          analogWrite(EN1,pwm); //set pwm control, 0 for stop, and 255 for maximum speed
         if(reverse)
         { 
          digitalWrite(IN1,HIGH);    
         }
        else
        {
          digitalWrite(IN1,LOW);    
         }
        }  
         
void Motor2(int pwm, boolean reverse)
        {
          analogWrite(EN2,pwm);
         if(reverse)
         { 
          digitalWrite(IN2,HIGH);    
         }
        else
        {
          digitalWrite(IN2,LOW);    
         }
        }  
        
void setup() 
{ 
    int i;
   // for(i=6;i<=9;i++) //For Roboduino Motor Shield
   // pinMode(i, OUTPUT);  //set pin 6,7,8,9 to output mode
 
    for(i=4;i<=7;i++)  //For Arduino Motor Shield
    pinMode(i, OUTPUT);  //set pin 4,5,6,7 to output mode
 
    Serial.begin(9600);   
} 
 
 
void loop() 
{ 
  int x,delay_en;
  char val;
  while(1)
  {
    val = Serial.read();
    if(val!=-1)
       {
          switch(val)
           {
             case 'w'://Move ahead
                        Motor1(255,true);  //You can change the speed, such as Motor(50,true)
                        Motor2(255,true);
                       
                         break;
             case 'x'://move back
                        Motor1(255,false);
                        Motor2(255,false);
                         break;
             case 'a'://turn left
                        Motor1(255,false);
                        Motor2(255,true);
                         break;       
             case 'd'://turn right
                        Motor1(255,true);
                        Motor2(255,false);
                        break;   
               case 's'://stop
                        Motor1(0,false);
                        Motor2(0,false);
                         break;
                                   
           }     
         
       }
            
  }                           
}