loading
 
Xbee with Arduino
Techdetect from United States  [28 posts]
11 year
Harold,

Would you be willing to share your robo setup using the Xbee, Arduino and joystick.
Techdetect from United States  [28 posts] 11 year
Nevermind, figured it out, Now I'm cooking with Crisco.
Techdetect from United States  [28 posts] 11 year
Replied too quickly, sorry,

I did get the xbee to work with the Freeduino arduino and one servo using my pan/tilt routine that i have posted about earlier this year.

However, I would like to use the seeedstudio motor shield that i have to get two dc motors to run.  Plans after that are to use a wireless camera too.
My problem is that there are 6 variables that i need to declare in VBScript to get this working.  Two are analog pins that i believe that can just be set to high in order to enable the bridge.
AnalogPIN1 = 255
SetVariable"AnalogPIN1","{analoghigh}"
This declares the variable for the arduino module to set the enable pins to high {255}

The other four are split out in pairs and are to drive two motor logic pins.  For example A and a B, then a C and D.


I was then going to declare an if else statement to get the digital pins to go high and or low depending on my KeyBoard Read setup,  CURSOR UP, CURSOR DOWN, CURSOR LEFT, CURSOR RIGHT.  Here are the pins to be interfaced with.
They must use the arduino pins as labelled.

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor

To get the motor to go forward the pin states would have to read as this:
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
     analogWrite(speedpinB,spead);
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
     digitalWrite(pinI1,HIGH);

DigitalWriteHIGH = 255
DigitalWriteLOW = 0
SetVariable"Cursor Right","{RIGHT}"

SetVariable"Cursor Left","{LEFT}"

SetVariable"Cursor down","{DOWN}"
SetVariable"Cursor up","{UP}"

This is where i have been stumped, I am missing something, yes, experience and knowledge is one thing but would still like some help.  Thanks


Can you help or anyone else.  I would like to write up a tutorial and post a video on this which should help anyone with a H-bridge as well.  Thanks, Techdetect.
Anonymous 11 year
Techdetect,

Are you taking about the Keyboard_Read or Keyboard_Send?

The commands above seem to be for the Keyboard_Send. The Keyboard read would be a bit different.

Perhaps you can include the robofile so that we can be sure what you are trying to do?

STeven.
Techdetect from United States  [28 posts] 11 year
Well, to be honest, I am not sure on which to use, keyboard send or read.  I am trying to use xbee and was able to use the "serial" command to send what i have already programmed into my arudino 'a' goes left, 'd' goes right, 'w' goes forward, and 's' goes backward, while 'f' stops all since it is configured that way, would of liked to use the arrow keys but will settle for this for now.  

Once i use the "serial" module through the "console"sending  the a, w, s, d, f, one at a time all works just fine.  Just can't figure out anything from there.  

I know that Roborealm does work with xbee just having a time of it..  
Here is the robofile or very lack of from what i was working on "please excuse me as i am reallllly lost..

My goal is to use roborealm to control a robot using xbee.  thats it..  after that i would like to go for using a wireless cam  attached to said robot.  THEN the good stuf and have roborealm control the robot , but first things first..
Thanks for your reply ST_G
program.robo
Techdetect from United States  [28 posts] 11 year
Any help is grateful.

so, forget the vbscript that i posted, doesn't work duh!.  If i write the VBscript to send only keystrokes, a, w, s, d and f for stop what would that look like.  Which module would best to send keystrokes or perhaps a joystick using the serial module.  I tried to copy the ssc and modify the move = 0 to move = a but that didn't work. must be the behind the scene scripting or something.  

Again, would like to use the serial module if possible (because it works but only one character at a time) , now to use joystick if that is the only thing to work or even keyboard but need help - please point in right direction.... am i suppose to write in the initiallization sequence?  " Note that this is different from the send sequence which will be sent each time the serial module is encountered in the processing pipeline. The Send Now button is a manual testing mechanism meant for debugging purposes::"  

HELP..><
Techdetect from United States  [28 posts] 11 year
Here is another VB that i have tried to mod, to no avail.  I think i have to look into the arduino code to get to work, not sure, thought robo could change the variables that i need.  Still working though. Would like to see or post a tutorial on this..
program.robo
Steven Gentner from United States  [1446 posts] 11 year
Techdetect,

It seems that you are well on your way to the right solution ... you just need a tidbit of information:

SetVariable "move", a

means set the variable "move" to the value within the variable "a". I think what you actually want is

SetVariable "move", "a"

which will assign the letter 'a' to the variable move which will then be transmitted via serial.

Make that change in the VBScript and things should hopefully get a bit more active.

STeven.
Techdetect from United States  [28 posts] 11 year
Little pig goes, "Weeeeee all the way home".  It did work!  I couldn't show you enough gratitude as a simple post couldn't give it justice.  Just know that I am grateful for your post.  

I would like to get advise/critic on the tutorial that will follow this huge accomplishment for me so that the steps can be followed for a complete newbie or perhaps a reminder for the experienced.  What is the best way to contact you with this "info"?
Thanks STeven, very pleased customer.
Techdetect from United States  [28 posts] 11 year
Here is the Arduino 1.0.1 code and the RoboFile:  enjoyment for all, See youtube video for "toddobot" search roborealm arduino xbee on youtube.

int digitalPin1=8;//define digitalPin1 to Seeedstudio motor shield interface
int digitalPin2=11;//define digitalPin2 to Seeedsudio motor shield interface
int enableMotorA=9;//enable motor A "Arbitrary pick one dc motor and connect it"
int digitalPin3=12;//define digitalPin3 to Seeedstudio motor shield interface
int digitalPin4=13;//define digitalPin3 to Seeedstudio motor shield interface
int enableMotorB=10;//enable motor B "You should have by now, determined the
int spead =150;//define the spead of motor

void setup()
{
  Serial.begin(9600);
  pinMode(digitalPin1,OUTPUT);
  pinMode(digitalPin2,OUTPUT);
  pinMode(enableMotorA,OUTPUT);
  pinMode(digitalPin3,OUTPUT);
  pinMode(digitalPin4,OUTPUT);
  pinMode(enableMotorB,OUTPUT);
}

void straight()
{
     analogWrite(enableMotorA,spead);//input a simulation value to set the speed
     analogWrite(enableMotorB,spead);
     digitalWrite(digitalPin4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(digitalPin3,LOW);
     digitalWrite(digitalPin2,LOW);//turn DC Motor A move anticlockwise
     digitalWrite(digitalPin1,HIGH);
}
void backward()//
{
     analogWrite(enableMotorA,spead);//input a simulation value to set the speed
     analogWrite(enableMotorB,spead);
     digitalWrite(digitalPin4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(digitalPin3,HIGH);
     digitalWrite(digitalPin2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(digitalPin1,LOW);
}
void left()//
{
     analogWrite(enableMotorA,spead);//input a simulation value to set the speed
     analogWrite(enableMotorB,spead);
     digitalWrite(digitalPin4,HIGH);//turn DC Motor B move clockwise
     digitalWrite(digitalPin3,LOW);
     digitalWrite(digitalPin2,HIGH);//turn DC Motor A move clockwise
     digitalWrite(digitalPin1,LOW);
}
void right()//
{
     analogWrite(enableMotorA,spead);//input a simulation value to set the speed
     analogWrite(enableMotorB,spead);
     digitalWrite(digitalPin4,LOW);//turn DC Motor B move anticlockwise
     digitalWrite(digitalPin3,HIGH);
     digitalWrite(digitalPin2,LOW);//turn DC Motor A move clockwise
     digitalWrite(digitalPin1,HIGH);
}
void halt()//
{
     digitalWrite(enableMotorA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
     digitalWrite(enableMotorB,LOW);
      
}

void loop()
{
   if(Serial.available()>0)
  
    {
      
       byte info=Serial.read();
       Serial.println(info);
  
          if (info=='f'){
          halt();
                        }
               else if(info=='a'){
               left();
                  }
                else if(info=='d'){
                right();  
                  }
                else if(info=='w'){
                 straight();
                  }
                else if(info=='s'){
                backward();
                   }
    }

}

program.robo

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index