gpt4 book ai didi

python - RPI伺服帽子python3库抛出错误: 'board' has no attribute 'SCL'

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:14 24 4
gpt4 key购买 nike

无论我如何为 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'

我已经安装了 servo hat documentation 中引用的所有模块并且“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

我在安装了 Raspbian 9.6stretch 的 Raspberry Pi model 3B 上运行此程序。非常感谢任何和所有的帮助。

最佳答案

由于板安装不正确,我也遇到了同样的问题。如果像我一样你安装了https://pypi.org/project/board/不小心,执行以下操作:

  • pip3卸载板

  • pip3 安装 adafruit-blinka

关于python - RPI伺服帽子python3库抛出错误: 'board' has no attribute 'SCL' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54432417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com