AIServo.setPosition()

[AIServo86]

説明

Set the target angle of the servo.

Syntax

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

Parameters

  • 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.

Returns

None.

Example

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

See also


Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール