@DJ and team.
I give a small request that I hope you would consider adding to EZ-Script.
Would it be possible to add a new script command for servostop()? I'm not talking about the one the one that already exists for modified servos, but for standard ones (more like a stopservo() or possitionstop() command). The idea is to add this for things like controllers and joysticks.
E.g, you have a servo which has a centre possition of 90, and a set max possition of say 160, and a set speed of 2. When a button is pressed on a controller the servo starts to move from 90 towards 160, but if you release the button the servo stops in its current possition and stays there. Press the button again and it continued to travel towards 160, or back to 90 by pressing another button.
I'm aware that there are ways to write a script for this, but I've had a lot of trouble with it so far, and having a simple script command in the script menu would make things so much easier. Would it be something that you would consider adding? And if there is a command to do just this, then I apologise in advance and would appreciate someone informing me of what script command to use.
Thanks, Steve.
@steve... you mentioned that you need to push the button too many times unless you set the increment to 20... My example code would have to go in the button push script... It checks to see if you pressed the button too many times and have exceeded the 105 ceiling... it then sets the servo to back 105 until you press the down button (or whatever direction you are going)...
@Rich's solution to write separate scripts outside of the button push scripts and to use ControlCommand() to start and stop them is a better method... It keeps code shorter so you don have one massive complicated script that becomes difficult to read and debug....
No matter what I try, it's just not doing what I want it to. Here is what I have in the "button 2" config...
and the command script...
All it ends up doing is to travel the set distance even when button 2 is released. I am thankful for your help with this guys, but I just can't figure out what I want to do for this. The closest thing I have have gotten to what I'm asking is to do "servospeed(d19,10)" in "when button is released", which doesn't stop the servo, just slows it down a lot. Having an "11" option that completely stops the servo for example, or a simple script command to accomplish the same thing would be so much easier and removes the need for scripting, just like the other servo script commands that already exist.
The command script has invalid syntax on line 1, presumably a typo?
Why does your ServoUp() have a step of 120? That would put the servo in position 120 higher than it is currently in. Why does the ControlCommand() script move the servo to position 120? This would completely go against the point of the small increments.
I've provided you with a script which would work to achieve stepping up or down of a servo. Use it in conjunction with ControlCommand() and ScriptStart and ScriptStop on the button down and button up commands.
Sorry, the 120 was a typo. Should have been 20. Don't know what you mean about typo in line 1. If you mean the brackets (), they were needed or the script wouldn't run.
is incorrect syntax
The correct syntax is
Brilliant. Thanks rich. No it wasn't a typo, just my bad coding. I'll try it again a bit later. Had to step away for a while and chill. Getting a lil bit stressed (if you couldn't tell).
Have a look at this project. In the example it uses the methods which have been explained and advised in this topic.
On pressing button 1 the servo will move in to it's maximum position at 1 degree steps with a 10ms delay between steps. On release it will stop in it's current position. Button 2 does the same but moves the servo down to it's minimum position.
The scripts use a basic loop and an IF surrounding a ServoUp or ServoDown command. Every time the script loops the servo moves one more degree unless the IF condition is not met. The script is triggered with ControlCommand() and ScriptStart. On release of the button the ControlCommand() uses ScriptStop to halt the script from running and therefore stopping the servo in it's current position.
To increase the servo movement speed decrease the sleep or increase the number of degrees. To slow it down increase the sleep time or decrease (if possible) the number of degrees.
As usual, I am benefiting from the help you are providing others. This is perfect for something I was working on (controlling the claws on my Roli)
Alan