
Hello there.
I need a little help with something, but I'm not sure if it is even possible. Is there a way to use one joystick button to move a servo in to two positions with two presses. Here's what I mean...
Servo is at center (possition 90)
Press button 1 and servo turns left (possition 1).
No button release script so servo stays left (possition 1).
Press button 1 again, and servo moves back to center (possition 90).
No button release script, so servo stays center (possition 90).
Press button 1 and servo turns left (possition 1)
and so on.
I have had a look through the script menu but have not seen anything to help me accomplish this (unless I missed it of course) and I'm not sure if it is even possible. I would like to do this just so I can free up some buttons on my controller.
If anyone has had experience with this or know what script to use, then your help would be most appreciated.
Steve.
@Steve G... We should keep everything here as it all pertains to the same questions you are asking..
Just start a new script control and name it "Init" or whatever you want... type in the following...
Keep it on your desktop of ARC and just run it one at the beginning... that's it. You can run it anytime you like if you ever need to change the speed and then want to go back to a slower speed...
@Richard.
Everything seems to be working so thanks for your help (and patience). I do have one additional question for you or anyone who knows.
I have a controller button scripted "when button is pressed" to move a servo from possition 90 to 160, and have nothing scripted on "when button is released" so servo moves from 90 to 160 even if I release the button. What peace of script do I need to write in "when button is released" to stop the servo in its current possition when I do release the button between positions 90 to 160?
I have looked through the script manual and the only thing I thought would work was the STOP() command, but as you probably know that's for a modified servo and doesn't work on a standard one.
A few questions...
Is the position always 90 before it moves to 160? What moves it back to 90? Is servo speed set at all?
By using the command Servo() the servo will jump to position rather than move to position. Meaning that stopping the script wont effect the position, it's either 90 or 160.
Using ServoUp() or ServoDown() in a loop can stop mid position.
Using the Auto Position Movement control may also give better results.
Hi Rich.
Yes the rest possition is 90 and maximum travel is 160. Button one on the joystick does this.
Servo speed is set to 2 in both directions.
Button 2 returns servo back to 90.
Basically the set up is for a head looking up (button 1 to 160) and looking down (button 2 back to 90) but I would like to stop the head looking up when I release button 1 (anywhere between 90 and 160), and then the same for looking down. Hope that all made sense
.
Check out the ServoUp() and ServoDown() commands. Used with some Ifs should achieve what you want.
Have the servo move one position at a time (or more if it's too slow) until it hits the limit.
IF it hits the limit then do nothing. ElseIf it's less than the upper limit (or more than the lower limit depending on direction) then move the servo up or down by x number of positions. It's less code and more efficient to switch that around, so IF it's less than the upper limit move the servo up a position otherwise don't do anything.
The sleep and number of servo positions to move in the ServoUp/ServoDown command will determine the movement speed.
I think he is putting the code in both Button Pressed and Button Released. Which is why this experience is occurring.
The code that was provided to you for pushing the button only needs to be in one of the two locations.
Do you want the action to run when the button is pressed or do releases? Choose one and place the code in the respective area.
Rich, you are my hero.
The little bit of script you supplied worked great
. I played around with the servo up/down values and got it moving just how I wanted. And a couple of rapid pressed of the joystick button still produced a nice smooth motion. And an added bonus is if the servo buzzes, a quick pulse or 2 of the button stops the buzz.
Again thanks very much for that. Much appreciated
.
@DJ.
You posted exactly the same time I just did lol. I've just got home and only just tried it out. No I deleated the script I originally had in the "button release" and now left it blank. I did want it to run on "button pressed". Works great now.