I wasn’t sure the best place to post this, so hopefully this is the right topic.
I’m attempting to run a pan/tilt set up of Goteck Metal Gear Micro Servos through I2C on my Raspberry Pi 1 using an Adafruit 16 channel Servo driver (PCA9685)
I created the following test code in Thonny to get all my connections right and test range of motion and it worked just fine:
import time
from adafruit_servokit import ServoKit
Set channels to the number of servo channels on your kit
kit = ServoKit(channels=16)
Limit range of servo, center point at 70 deg
kit.servo[1].actuation_range = 180
print(“test commencing in 5 seconds”)
time.sleep(5)
Test sweep “hor_servo” on channel 0
kit.servo[0].angle = 160
time.sleep(1)
kit.servo[0].angle = 0
time.sleep(1)
kit.servo[0].angle = 80
print(“Pan OK!”)
time.sleep(2)
Limit range of servo, center point at 40 deg
kit.servo[4].actuation_range = 180
Test sweep “vert_servo”
kit.servo[4].angle = 0
time.sleep(1)
kit.servo[4].angle = 130
time.sleep(1)
kit.servo[4].angle = 40
print(“Scan OK!”)
Now I’m trying to take the next step and control the servos through an app I built for my Android. Before I began I tested the above program running through the Raspberry Pi Terminal to make sure it would still work as intended. My print statements came out fine, but my servos didn’t move, despite everything being wired exactly the same as when they were working properly. This is what I had in Terminal:
pi@raspberrypi:~/Documents/Pi Programs $ python3 ‘Servo Startup Test.py’
test commencing in 5 seconds
Pan OK!
Scan OK!
It may also be worth noting that where before I was working directly on the Pi, this time I’m connected to it through ssh on my Ubuntu desktop.
If anyone has any suggestions as to what I might have screwed up, I would appreciate your thoughts.
Thanks
Amanda