Servo86.setVelocity()

[Servo86]

描述

Set the rotation speed of the servo when write() 以及 run() are called next time.

Please note that if you set the rotation time when you call setPosition(), the rotation speed set by this function will not have any effect.

語法

servo.setVelocity(value)

參數

  • servo: The variable of Servo type.
  • value: The speed of the servo, integer and floating point type values can be entered. When inputting an integer, the unit of rotation speed is us/s, for example, input 1000, which means 1000us of rotation per second. When a floating point number is entered, the unit of rotation speed is angle/s. For example, if 1.5 is entered, it means 1.5 degrees per second. If the input value is 0 or 0.0, it means the servo will rotate at the fastest speed.

回傳

範例

#include <Servo86.h>
  
Servo myservo;
  
void setup()
{
   myservo.attach(9);
   myservo.write(1500); // Rotate the servo to 1500us angle
   myservo.setVelocity(1000); // set velocity 1000us/s
   myservo.write(900); // start the servo and turn to the 900us angle with a speed of 1000us/s
}
  
void loop() {}

參考


函式庫參考主頁面

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

發表評論

上部へスクロール