Servo86.setPosition()

[Servo86]

説明

Set the target position of the servo when run() is called.

Syntax

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

Parameters

  • servo: The variable of Servo type.
  • Position: The target position of the servo. You can input integer and floating point values. When inputting an integer, the unit of the target position is us. For example, inputting 1500 represents the position of the servo corresponding to the PWM pulse of 1500us. When the input is a symbolic number, the unit of the target position is “degree”, for example, enter 90.0 to represent the 90 degree position of the servo.
  • Time (optional): Specify the desired time for the servo to rotate from the current position to the target position. If the input value is 0, the servo will rotate at the fastest speed; if there is no input value, the servo will rotate according to the speed set by setVelocity().

Returns

None.

Example

#include <Servo86.h>
  
Servo myservo;
  
void setup()
{
   myservo.attach(9);
   myservo.setPosition(1500); // set the rotation to 1500us angle
   myservo.run(); // turn the servo
   delay(500); // delay 0.5 seconds
   myservo.setPosition(1900, 1000); // set the rotation to 1900us angle, 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下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール