|
- import sys
- import time
- import board
- import busio
- import json
-
- from adafruit_motor import servo
- from adafruit_pca9685 import PCA9685
-
- filename = sys.argv[1]
- with open(filename, "r") as f:
- calibration = json.load(f)
-
- print(calibration)
-
- i2c = busio.I2C(board.SCL, board.SDA)
- pca = PCA9685(i2c)
-
- pca.frequency = 50
- servo_pwm = pca.channels[0]
-
- servo = servo.Servo(pca.channels[0], actuation_range = 180, min_pulse=round(calibration['intercept']), max_pulse=round(calibration['intercept'] + 180 * calibration['slope']))
-
- servo.angle = 90
- time.sleep(2)
- servo.angle = 0
- time.sleep(2)
- servo.angle = 180
- time.sleep(2)
- servo.angle = 90
|