Hello, My name is Greg.
I am just starting out with arduino. I am looking to build a robot with four wheels that i can control from a max distance of 100 meters. I am thinking of using the Xbee to control this, but am very confused as to how to make a controller that will communicate it and how to control the motors. I am using VEX 393 motors with VEX motor controller 29's, which i use the servo library to control. I know how to control the motors, but how to i communicate across the Xbee? does anyone have sample code for controlling a servo with a joystick? I'm looking for the simplest code possible to study and learn from. Thank you. Or if you know of any good videos that will explain it very simply?
So in short: How do i control a servo hooked up to an arduino uno and Xbee from another arduino and xbee that has a joystick hooked up to it?
What is the simplest way to hook up an xbee if this is all i want to do?
(I am big into vex robotics, but the programming for those is quite a bit different, and i would love to learn arduino but i am having a very hard time finding good resources.)
Thank you so so much for any help.
For starting out, i guess i would just like the servo to move clockwise when it is moved right, and counterclockwise when it is moved left.
A joystick reading will vary from 0 to 1023, with 512 (approximately) being centered. You need to be much more explicit as to what any given value read from the joystick means in terms of servo angle.
ggurta:
In that case, here is some basic pseudo-code to what i was thinking.
If JoystickReading > 514, Set servo to 1000
If JoysitckReading < 510, Set servo to 2100
Else Set servo 0
So, as long as the stick is forward, regardless of how far, turn the motor a constant speed one way. As long as the stick is pulled back, regardless of how far, turn the motor a constant speed the other way. That's not what most people would do/expect.
Yes, i understand that. I will work out how to do variable speed control later, but right now i'm trying to just figure out how to use the xbee. The simpler i can make this to try to get assistance using the xbee, the better. I am just trying to figure out how to transmit and recieve anything over the xbee
I am mainly looking for some sort of sample code to study if anyone has some...i cannot find any
I am just trying to figure out how to transmit and recieve anything over the xbee
That should happen only AFTER you have the system working with wires.
How is the XBee connected to the Arduino? A link to the shield you are using would be useful.
If the XBee is connected to pins 0 and 1, Serial.print("send some data"); is all you need. If the XBee is connected to two other pins, create an instance of SoftwareSerial using those two pins, calling the instance xbee. Then, xbee.print("send some data");.
I have not bought the Xbee shield or Xbee yet, because i was worried it would be over my head. Before i buy it i'm trying to figure out some basics about it.I really have no idea what shield is best, or what wires should go where. That's what i would like to know before i go and buy one. Is there any good documentation or tutorials out there? Or is this actually just super easy to use?
Again i am very new to arduino, and just a few basic pointers of where to look for info to be nice (info on how to wire things up, and basic code using the Xbee. I still dont get how the serial.print works. When you print Motor.write(1000) will the other xbee receive that and then just make the motor run? is that all there is to it?
Once the radios are configured everything will be done via serial communication, just as if you were typing into the serial monitor. It will be up to the Arduino code to make sense of what it is receiving.
Check out the chat program examples provided by Digi. They have an example for series 1 and series 2 XBees. You will have the radios set up the same way but they will be connected to the Arduino instead of a computer.
@PaulS I was talking about controlling the motor from the xbee
Could someone point me in the direction of a good explanation of what serial communication is and how it works? I have not yet used it and have only done basic things like autonomous motor control or LED control...
also the link about using two computers... it talks about downloading a program. I obviously cant do that for an arduino, because arduino does not support windows programs... So how do i go about linking the two for communication?