Servo86.run()

[Servo86]

描述

Command the servo to rotate to the target position set by setPosition().

After calling run(), your program can do other things and the work of rotating the servo will be executed in the background. If you want to know whether the servo is rotating to the target position, you can call isMoving() or isServoMultiMoving() to check.

Please note that when the servo is in the disengaged state, this function will make the servo to come out of force immediately.

語法

servo.run()

參數

servo: Variable of the servo type.

回傳

範例

#include <Servo86.h>
  
Servo myservo;
  
void setup()
{
   myservo.attach(9);
   myservo.setPosition(1500); // Set to rotate to 1500us angle at the fastest speed (the first rotation must be the fastest speed)
   myservo.run(); // turn the servo
   delay(1000); // stop at 1500us angle for about 1 second
   myservo.setPosition(1000, 1000); // set to 1000us angle, it takes 1 second
   myservo.run(); // turn the servo
}
  
void loop() {}

參考


函式庫參考主頁面

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

發表評論

上部へスクロール