I am using a Raspberry Pi model 4B and a Tower Pro servo SG51R which only turns 180 degrees. I am writing code on the Raspberry Pi to control the servo (which works as I have tested it with my Arduino Uno, it responds and works correctly) with Python.
I installed the gpiozero
library successfully on my Raspberry Pi using the below commands:
sudo apt-get install python3-rpi.gpio
sudo pip install gpiozero
I then connected my servo to the Raspberry Pi similar to the diagram shown below
I made sure the brown wire connected to GND, the red wire to a 4.8 volt power supply. and the yellow wire to the GPIO pin 25 (normal pin 22).
I then ran the below code:
from gpiozero import Servo
test = Servo(22)
print('moving')
test.max()
print('done moving')
from time import sleep
sleep(1)
print('moving again')
test.min()
print('finished second movement')
sleep(5)
test.value = 0
sleep(1)
test.value = 1
sleep(1)
test.value = -1
print('done entirely')
and received the below output:
/usr/lib/python3/dist-packages/gpiozero/output_devices.py:1532: PWMSoftwareFallback: To reduce servo jitter, use the pigpio pin factory.See https://gpiozero.readthedocs.io/en/stable/api_output.html#servo for more info
warnings.warn(PWMSoftwareFallback(
moving
done moving
moving again
finished second movement
done entirely
Yet the servo still does not move. I even tried using a different servo of the same model, and using different pins to no avail. Is there anything else I’m missing? How could I make this work?