Servo86.setRealTimeMixing()

[Servo86]

描述

Compensates the specified value to the current position control cycle of the servo.

For some robots with sensors (such as gyroscopes or accelerometers), this function can be used to feed back the physical quantities detected by the sensors to the robot’s motion.

語法

servo.setRealTimeMixing(value)

參數

  • servo: Variable of servo type.
  • value: Position compensation value in us, which is added to the target angle calculated by the current position control cycle of the servo in real time when the servo is running.

回傳

範例

#include <Servo86.h>
 
Servo myservo;
 
void setup()
{
   myservo.attach(9);
   myservo.setPosition(1500); // set the target angle: 1500us
   myservo.run(); // turn the servo
   while(myservo.isMoving() == true); // wait for the servo to reach the target angle
 
   int i = 0;
   myservo.setPosition(2000, 5000); // set target angle: 2000us, time spent: 5 seconds
   myservo.run(); // turn the servo
   while(myservo.isMoving() == true)
   {
     i = (i + 10) % 400; // simulate the change of feedback angle
     myservo.setRealTimeMixing(i);
   }
}
 
void loop() {}

參考


函式庫參考主頁面

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

發表評論

上部へスクロール