radiogareth
Senior Member
Very simple circuit, 3 servos on an 08M2, Pins 0,1&2.
I want them to move slowly in both directions in a sort of anti-phase - the middle servo drives in the opposite direction to the left and right ones.
What I'd like is for all 3 servos to go at the same speed in EACH direction, but with 3 on the go I cant think of a way to achieve this. One would be easy, but three....some clever nesting may be required.
TIA for suggestions.
I want them to move slowly in both directions in a sort of anti-phase - the middle servo drives in the opposite direction to the left and right ones.
What I'd like is for all 3 servos to go at the same speed in EACH direction, but with 3 on the go I cant think of a way to achieve this. One would be easy, but three....some clever nesting may be required.
TIA for suggestions.
Code:
init: 'sets all three servos up to central position on pins 0,1 &2
servo 0,150 '150 being approximately their central position
servo 1,150 'You will need to experiment with different servos
servo 2,150 'to find the end stop limits. Don't drive them beyond this point
'set up startpoints - these can be adjusted up or down as you wish
b0=60
b1=90
b2=120
automatic_advance:
inc b0:if b0 > 180 then let b0=60:endif 'This increments each variable until
dec b1:if b1 < 60 then let b1=180:endif 'your chosen end position is reached
inc b2:if b2 > 180 then let b2=60:endif 'then it resets them
'Drives each servo to its new position using relevant variable
servopos 0,b0
servopos 1,b1
servopos 2,b2
'Reads a potentiometer across the V supply feeding ADC4
readadc 4,b3 'stores it in B3
pause b3 'uses B3 for the delay, effectively slowing the servos
goto automatic_advance 'goes back and does it all again
'loop back to start of main loop
Last edited: