Any tips or a line of python code that allows me to access this feature is appreciated. I found an old script that uses that PCA9685 library to send these pulses, but it does not work any more and when looking into the library I do not see this class. I will put the script below.
The function of this is to have a "clock" that instead of hands pointing to certain times, it points to the current location of each user. If you believe this PWM feature is no longer available, a recommendation for a servo that I can purchase would be appreciated, I am new to all of this. Thank you.
Code: Select all
from __future__ import division
import time
# Import the PCA9685 module.
import Adafruit_PCA9685
# Import sys module for accepting variables
import sys
# Initialise the PCA9685 using the default address (0x40).
pwm = Adafruit_PCA9685.PCA9685()
#Time to set variables for which servo to use and what location
#to move to.
servo_number = sys.argv[1]
location = sys.argv[2]
#The location_list compares the location variable with the
#13 locations I have on the clock face
#PWM list is the PWM off values I need to enter to point in the right directions
location_list = ['Home','Lessons','Concert','Lost','Tavern','Mortal Peril','Opera','Siblings','Travel','Doctors','Work','Parents','School']
PWM_list = [246, 287, 328, 369, 410, 450, 491, 532, 573, 614, 655, 696, 717]
for idx, location in enumerate(location_list):
PWM_index = idx
servo_max = PWM_list[idx]
# Configure min and max servo pulse lengths
servo_min = 246 # Min pulse length out of 4096. This sets you back to Home
# Helper function to make setting a servo pulse width simpler.
def set_servo_pulse(channel, pulse):
pulse_length = 1000000 # 1,000,000 us per second
pulse_length //= 60 # 60 Hz
print('{0}us per period'.format(pulse_length))
pulse_length //= 4096 # 12 bits of resolution
print('{0}us per bit'.format(pulse_length))
pulse *= 1000
pulse //= pulse_length
pwm.set_pwm(channel, 0, pulse)
# Set frequency to 60hz, good for servos.
pwm.set_pwm_freq(60)
print('Moving servo on channel 0, press Ctrl-C to quit...')
while True:
# Move servo on channel O between extremes.
pwm.set_pwm(servo_number, 0, servo_min)
time.sleep(1)
pwm.set_pwm(servo_number, 0, servo_max)
time.sleep(1)