Servo program works from Thonny, but not from Terminal

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

Hi @KingKrawlers
how did you supply power to the ServoKit and the Pi? If only powered from USB, it might not be enough current for the servos.

It’s powered by a 12V, 1A DC wall adapter stepped down by a 12V to 5V voltage converter.

I must have messed something up since the last time I had it all working, because I have since tested the setup with the original configuration (using Thonny directly on the Pi) and that’s not working anymore either.