Posted: 05:16pm 27 Oct 2022 |
|
|
|
Hi Rick,
Not really needed The servo command is the same as the PWM command
Assume you want to set an angle between 0 and 180 degrees (90 is centre position) then use:
PWM x,50,5+angle/36
See below code as an example:
servo signals range from 1ms (5%) to 2 ms (10%) on 20ms frame rate
'set up the PWM for 2 servo's setpin gp2,pwm1a setpin gp3,pwm1b
'start the PWM's in mid position PWM 1,50,7.5,7.5
'vary the angle do for angle=0 to 180 step 10 '90 degrees is mid position pause 100 pwmval=5 + angle/36 PWM 1,50,pwmval,pwmval next loop
sweeps 2 servo's from left to right.
Make sure you have sufficient 5V power for the servo's. The USB is not sufficient !!!
Volhout |