伺服馬達#

介紹#

VEX 三線伺服馬達 是一款三線設備,可根據 V5 控制器的控制訊號旋轉到特定位置。

VEX 三線伺服馬達。

本頁使用 servo_motor 作為範例伺服馬達名稱。請根據需要將其替換為您自己配置的名稱。

以下是可用方法清單:

  • set_position – 將伺服馬達移到 0 到 100 度之間的指定位置。

建構函式 - 手動初始化伺服馬達。

  • Servo – 建立一個伺服馬達。

設定位置#

set_position 將伺服馬達移到 0 到 100 度之間的指定位置。

注意:伺服馬達在開始每個項目之前,都會自動將自身居中於 50 度,然後再進行任何運動。

伺服馬達示意圖,顯示其旋轉角度,從左側的 100 度到中間的 50 度,再到右側的 0 度。

Usage:
servo_motor.set_position(value, units)

參數

描述

value

The position value to set for the Servo Motor. This can be an integer or decimal (float) from 0 to 100.

units

位置單位: DEGREES 或 PERCENT (預設值)。

建構函數#

建構函數用於手動建立 Servo 對象,這是在 VEXcode 之外配置伺服馬達所必需的。

Servo#

Servo 創建一個伺服馬達。

Usage:
Servo(port)

範圍

描述

port

The 3-Wire Port that the Servo Motor is connected to:

  • On the V5 Brain – Ports.PORTx where x is the number of the port.
  • On a 3-Wire Expander – expander.a where expander is the name of the expander instance.

# Create a Servo Motor in Port A
servo_motor = Servo(brain.three_wire_port.a)