AIServo.setPosition()

[AIServo86]

描述

Set the target angle of the servo.

語法

servo.setPosition(position)
servo.setPosition(position, time)

參數

  • servo: The variable of AIServo type.
  • position: The target angle of the floating-point number type, e.g., 90.0, the target position is in “degrees”, i.e., 90 degrees of the servo.
  • time (optional): If there is no input value or the input value is 0, it means the servo will rotate at the fastest speed.

回傳

範例

#include <AIServo86.h>
  
AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo;
  
void setup()
{
   bus.begin(Serial1, 1000000);
   myservo. attach(bus, 9);
   myservo.setPosition(150); // Set to rotate to 150 degrees at the fastest speed
   myservo.run(); // turn the servo
   myservo.setPosition(100, 1000); // set to turn to 100 degrees, it takes 1 second
   myservo.run(); // turn the servo
}
  
void loop() {}

參考


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール