伺服#
初始化伺服类#
使用以下构造函数创建伺服输出:
Servo(port)
此构造函数使用一个参数:
范围 |
描述 |
---|---|
|
必须先创建 Brain 或 3-Wire Expander,然后才能使用 Servo Class 构造函数创建对象。
# Create the Brain.
brain = Brain()
# Construct a Servo Output "servo" with the Servo class.
servo = Servo(brain.three_wire_port.a)
当引用 Servo 类方法时,此 API 文档中的所有后续示例中都将使用此 Servo
对象。
类方法#
set_position()#
set_position(value, units)
方法设置伺服器的位置。
参数 |
描述 |
---|---|
价值 |
伺服的新值。 |
单位 |
**可选。**有效的 RotationUnits 类型。默认值为 |
**返回:**无。
# Set the Servo Output to 10 degrees.
servo.set_position(10, DEGREES)