Does anyone have any code they could share that would turn a servo from side to side. I need it to move the servo from position 50 to position 80 and back again not exceeding those positions but I cant seem to figure out the logic to make it happen. Any examples?
Something like this may give you some help too. I use these two scripts attached to joystick buttons to open and close a claw as long as I am pressing the button. You could adapt the function to your needs but not exceed the min or max values.
Alan
I would like to thank everybody. The example code and explanation was just what I needed. What I've noticed is that by running the code this way I have to way for the slewing to complete. Is there a way to do two things at once? Meaning I would like it to go up/down and side/to side, like tracing a W. Any thoughts or suggestions?
Do you mean two servos like a pan/tilt?
If you use something like my last example where you are moving a little at a time in a loop, you would just issue two commands, one to each servo before looping. The commands will execute so fast that they will be simultaneous for all intents and purposes.
Alan
Another way you could do it using the example in post #7, is to add another servo command before the sleep() (anything before the sleep will run at the same time).
Obviously, change where you want your max positions to go, and as already mentioned, servo speeds, and length of sleeps where you need to.