[Servo86]
描述
The servo is reporting whether it is rotating or not.
語法
servo.isMoving()
參數
servo: Variable of the servo type.
回傳
If the servo is rotating, return true; in other conditions (e.g., servo is paused, stopped, released, or has reached the target position), return false.
範例
#include <Servo86.h>
Servo myservo;
void setup()
{
myservo.attach(9);
myservo.write(1500); // turn the servo to the initial position of 1500us
delay(1000);
myservo.setPosition(1800, 3000); // Set the target angle of the servo: 1800us, time: 3 seconds
myservo.run();
delay(1000); // the 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() {}參考
- write()
- writeMicroseconds()
- setPosition()
- run()
- pause()
- resume()
- stop()
- release()
函式庫參考主頁面
86Duino 參考的文本是根據 知識共享署名-相同方式分享 3.0 許可證,部分文本是從 Arduino 參考 修改的。 參考中的代碼示例已發佈到公共領域。