
PRO
dbeard
USA
Asked
— Edited
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?
Code:
You can enhance this is with the addition of a servospeed command if you want to slow it down (but will need to use a longer sleep).
If you want it to repeat you can use a label and goto, or if you want it to repeat until some condition is met you could use repeat until or repeat while commands.
Alan
Servo(d1,50)
sleep (600)
Servo(d1,60)
sleep (600)
servo(d1,70)
sleep (600)
servo(d1,80)
Code:
Code:
Code:
Alan
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
Code:
Obviously, change where you want your max positions to go, and as already mentioned, servo speeds, and length of sleeps where you need to.