ServoOffset 建构子
描述
初始化 ServoOffset 类别。
语法
ServoOffset myoffset
ServoOffset myoffset(filename)
参数
filename
:伺服机偏移量微调值档案名称。
如果有输入以上参数,则 ServoOffset 在初始化类别时,会自动载入该档案内容做为初始的偏移量微调值。请注意,您必须将档案放在 SD 卡根目录下;假如您的 86Duino 没有置入 SD 卡,或者 SD 卡内不包含动作档案,则档案载入会失败。
范例
#include <Servo86.h> Servo myservo1; Servo myservo2; Servo myservo3; // 从 SD 卡中载入名称为 offset.txt 伺服机偏移量微调值档案 ServoOffset myoffset("offset.txt"); void setup() { myservo1.attach(21); myservo2.attach(23); myservo3.attach(25); // 设定各伺服机中心位置误差的补偿量 myoffset.setOffsets(myservo1, myservo2, myservo3); myservo1.setPosition(1000); myservo2.setPosition(1500); myservo3.setPosition(2000); servoMultiRun(); // 转动各伺服机(将自动补偿伺服机中心位置误差) } void loop() {}
See also
- offsets[]
- setOffsets()
The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.