AIServo.isMoving()

[AIServo86]

説明

Check if the Servo is rotating.

Syntax

servo.isMoving()

Parameters

servo: Variable of the AIServo type.

Returns

If the servo is rotating, the return is true; otherwise, the return is false (e.g., Servo is paused, stopped, released, or reached the target position).

Example

#include <AIServo86.h>
 
AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo;
 
void setup()
{
   bus.begin(Serial1, 1000000);
   myservo. attach(bus, 9);
   myservo.write(150); // turn the servo 150 degrees
   delay(1000);
 
   myservo.setPosition(180, 3000); // Set the target angle of the servo: 180 degrees, time: 3 seconds
   myservo. run();
 
   delay(1000); // Servo rotates for 1 second
   if(myservo.isMoving() == true) // check if the servo is moving to the target angle
     Serial.println("The servo is moving...");
   else
     Serial.println("The servo stops at target position");
 
   delay(3000); // Let the servo rotate to the target angle
   if(myservo.isMoving() == true) // check if the servo is moving to the target angle
     Serial.println("The servo is moving...");
   else
     Serial.println("The servo stops at target position");
}
 
void loop() {}

See also


Libraries Reference Home

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

コメントする

上部へスクロール