Button Control of servo
Tanner Garcia from United States  [1 posts]
12 year
Hello All, fairly new to all this so my apologies if this is extremely obvious.... But how the heck do you control a servo with two buttons on an xbox controller? I'm running through a Parallax servo controller and can control the servo with a joystick, but i havent gotten the button thing yet. It will be a servo controlled tilt for a camera and id like to be able to assign one button to up a little (20ish) and the other button to down.
Another thing im trying to do is use differential drive steering with the joystick (stick forward both motors forward, stick left = right motor forward left motor back) so help with either would be much appreciated.
Anonymous 12 year

How a look at the robofile in the top 3 tutorials in the joystick control area.

Basically, the idea for using a button is to increment or decrement a variable based on a button being on. The amount you use will determine the speed at which the variable changes.

For example, if you place a joy_button_1 in any of the joystick module variable fields and then follow that with a VBScript module which includes

if GetVariable("joy_button_1") <> 0 then
  SetVariable "my_value", GetVariable("my_value") + 10
end if

which will increment the variable my_value by 10 each time the button is pressed. To decrement just use another button and

if GetVariable("joy_button_2") <> 0 then
  SetVariable "my_value", GetVariable("my_value") - 10
end if

The tutorials contain info on using differential steering ... basically that's a mapping from the joystick value of -1000 to 1000 and convert that to 0 to 255 and send that to a servo/motor controller.


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