setVelocity()

描述

設定伺服機的轉速。 請注意,此函式只有在尚未設定轉動時間的情況下有效,若您已經呼叫 setPosition() 設定了轉動時間,此函式設定的轉速將不會有效果。

語法

servo.setVelocity(value)

參數

servoAIServo 型別的變數。 value:伺服機的轉速,單位為 度/秒,若設定的速度超越伺服機極限,伺服器將以最快速度轉動。若輸入值為 0 或 0.0,代表伺服機將會以最快的速度轉動。

回傳

範例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo;

  

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo.attach(bus, 9);

  myservo.write(150); // 將伺服機轉動到 150 度

  myservo.setVelocity(100); // 設定速度 100 度/秒

  myservo.write(90); // 啟動伺服機,用 100 度/秒 的速度轉到 90 度

}

  

void loop() {}

See also

attach()


函式庫參考主頁面

86Duino 參考資料中的文字修改自 Arduino 參考資料,並根據 知識共享署名-許可證方式共享 3.0 授權相同。參考資料中的程式碼範例已發佈到公共領域。