SparkFun Pi Servo pHAT: code, docs
- sparkfun-pi-servo-hat source,
- its dependency sparkfun-qwiic-pca9685,
- and I2C driver sparkfun-qwiic-i2c based on smbus2
import pi_servo_hat
import time
# Initialize Constructor
test = pi_servo_hat.PiServoHat()
# Restart Servo Hat (in case Hat is frozen/locked)
test.restart()
# Test Run
#########################################
# Moves servo position to 0 degrees (1ms), Channel 0
test.move_servo_position(0, 0)
# Pause 1 sec
time.sleep(1)
# Moves servo position to 90 degrees (2ms), Channel 0
test.move_servo_position(0, 90)
# Pause 1 sec
time.sleep(1)
# Sweep
#########################################
while True:
for i in range(0, 90):
print(i)
test.move_servo_position(0, i)
time.sleep(.001)
for i in range(90, 0, -1):
print(i)
test.move_servo_position(0, i)
time.sleep(.001)
Sidequest: I2C library in C
- A page from eLinux wiki, no
smbus
- libi2c. Note: it uses meson build system.
- i2c-exp-driver from Onion company
forks: