setVelocity()

描述

設定伺服機的轉速。

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

語法


servo.setVelocity(value)

參數

servoAIServo 型別的變數。

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

回傳

範例

#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()


函式庫參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.