I'm working on a project of a camera connected to a robotic arm that moves when my face is about to get out of the frame. I'm using 3 Tower Pro MG996R servos and they are connected to my raspberry pi. for some reason whenever I do a simple command like:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(2,GPIO.OUT)
x = GPIO.PWM(3,50)
x.start(0)
x.ChangeDutyCycle(8)
sleep(0.5)
x.stop()
GPIO.cleanup()
My servo will finish moving but at the end of the movement, it will jitter for about a second. Sometimes it will jitter and sometimes it won't. I couldn't find what makes it jitter. Would love to get some help on that. Thanks a lot.
Edit: I also tried using gpiozero and changing its Factory to pigpio pin factory. Sadly still jittering.
from gpiozero import Servo
from time import sleep
from gpiozero.pins.pigpio import PiGPIOFactory
factory = PiGPIOFactory()
servo = Servo(3,pin_factory = factory)
servo.mid()
sleep()
servo.min()
sleep()
servo.max()
sleep()
servo.value = None