小编har*_*sgs的帖子

RPI伺服帽子python3库抛出错误:“板”没有属性“SCL”

无论我如何为 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 上运行它。非常感谢任何和所有的帮助。

python python-3.x raspbian servo raspberry-pi3

3
推荐指数
1
解决办法
9890
查看次数

标签 统计

python ×1

python-3.x ×1

raspberry-pi3 ×1

raspbian ×1

servo ×1