run()

描述

啟動伺服機(即伺服機開始出力)。

假如您之前已經有呼叫 setPosition() 設定目標角度,伺服機會開始轉動至您設定的角度。

請注意,由於此函式會讓伺服機立即出力,請避免以手大力轉動伺服機,以免受傷或損壞伺服機。

語法


servo.run()

參數

servoAIServo 型別的變數。

回傳

範例

#include <AIServo86.h> 
 
AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo;
 
void setup() 
{ 
  bus.begin(Serial3, 1000000);
  myservo.attach(bus, 3);
  myservo.setPosition(200); // 設定以最快速度轉動到 200 度
  myservo.run(); // 轉動伺服機
  delay(1000);
  myservo.setPosition(100, 1000); // 設定轉到 100 度,用時 1 秒
  myservo.run(); // 啟動伺服機
  while(myservo.isMoving());
} 
 
void loop() {} 

See also

attach()
setPosition()


函式庫參考主頁面

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.