Description
Checks if the servo is moving.
Syntax
servo.isMoving()
Parameters
servo: A variable of type AIServo.
Return
Returns true if the servo is moving. Returns false otherwise (e.g., if the servo is paused, stopped, released, or has reached its target position).
Example
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#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 to 150 degrees
delay(1000);
myservo.setPosition(180, 3000); // Set the servo's target angle: 180 degrees, time: 3 seconds
myservo.run();
delay(1000); // The servo moves for 1 second
if(myservo.isMoving() == true) // Check if the servo has reached 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 whether the servo rotates to the target angle
Serial.println("The servo is moving...");
else
Serial.println("The servo stops at target position");
}
void loop() {}
|
See also
- attach()
- setPosition()
- isAIServoMultiMoving()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.