[AIServo86]
Description
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.
Syntax
servo.setRealTimeMixing(value)
Parameters
servo
: the variable of AIServo type.setRealTimeMixing
: the offset angle, in degrees.
Returns
None.
Example
#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); }
See also
Libraries Reference Home
The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.