无论我如何为 Adafruit RPI 伺服帽重写简单的 python 3 伺服测试脚本,我都会收到以下错误。
Traceback (most recent call last):
File "servo_test.py", line 8, in <module>
i2c = busio.I2C(board.SCL, board.SDA)
AttributeError: module 'board' has no attribute 'SCL'
Run Code Online (Sandbox Code Playgroud)
我已经安装了伺服帽子文档中引用的所有模块,并且“i2cdetect”已验证帽子是否正确连接。这是我当前的测试脚本(python 3):
#!/usr/bin/python
from adafruit_servokit import ServoKit
import adafruit_pca9685
import board
import busio
### board / servo hat setup ###
i2c = busio.I2C(board.SCL, board.SDA)
hat = adafruit_pca9685.pca9685(i2c)
kit = ServoKit(channels=16)
### test servo ###
kit.servo[0].angle = 60
Run Code Online (Sandbox Code Playgroud)
我在安装了 Raspbian 9.6stretch 的 Raspberry Pi model 3B 上运行它。非常感谢任何和所有的帮助。