As a newbie I'm testing my Pi2B with a Micro Servo SG90 attached. Im running the code below. It works quitte fine, but it doesn't hold the left and right position steadily, there are small vibrations. My Pi has a bluetooth mouse, and when I use it, the servo starts shaking heavily. How can I prevent this behaviour?
I use an external powersupply for the servo, but removing it and having the servo powered by the Pi doesn't solve it. Neither does using another usb charger for the Pi. Removing the bluetooth adapter from the Pi doesn't stop the small vibrations.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
p = GPIO.PWM(17, 50)
p.start(6.55)
for i in range(1000):
p.ChangeDutyCycle(6.55)
time.sleep(3)
p.ChangeDutyCycle(6.85)
time.sleep(3)
p.stop()
GPIO.cleanup()