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.

Syntax

servo.setRealTimeMixing(value)

Parameters

  • 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.

Returns

None.

Example

#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() {}

See also


Libraries Reference Home

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

コメントする

上部へスクロール