伺服#
初始化伺服类#
使用以下构造函数创建伺服输出:
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)
This Servo
object will be used in all subsequent examples throughout this API documentation when referring to Servo class methods.
类方法#
set_position()#
The set_position(value, units)
method sets the position of the Servo.
参数 |
描述 |
---|---|
价值 |
伺服的新值。 |
单位 |
Optional. A valid RotationUnits type. The default is |
**返回:**无。
# Set the Servo Output to 10 degrees.
servo.set_position(10, DEGREES)