[AIServo86]
描述
Set the servo offset angle dynamically.
When the servo is running, the offset value set by this function will be added to the target angle of the servo in real time so that the original target angle will have a positive or negative deviation. This function can be used by robots with sensors (gyroscope or accelerometer) to receive feedback values so that the feedback values can be instantly reflected in the robot’s motion.
語法
servo.setRealTimeMixing(value)
參數
servo
: the variable of AIServo type.setRealTimeMixing
: the offset angle, in degrees.
回傳
無
範例
#include <AIServo86.h> AIServoPort(ROBOTIS, AX12) bus; AIServo myservo; unsigned long_time = 0L; void setup() { bus.begin(Serial3, 1000000); myservo. attach(bus, 3); } void loop() { myservo.setPosition(300); // Set target angle: 300 degrees myservo.run(); // start the servo delay(1500); double i = -1; _time = millis(); myservo.setPosition(125, 3000); // Set target angle: 125 degrees, time spent: 3 seconds myservo.run(); // start the servo while(myservo. isMoving() == true) { if((millis() - _time) < 1000L) { i = i*2; if ( i < -100) i = -1; myservo.setRealTimeMixing(i); } } while(1); }
參考
函式庫參考主頁面
86Duino 參考的文本是根據 知識共享署名-相同方式分享 3.0 許可證,部分文本是從 Arduino 參考 修改的。 參考中的代碼示例已發佈到公共領域。