capture()
描述
读取指定 KONDO 伺服机的当前位置。
KONDO 的 RC 伺服机提供了回传当前位置的特殊功能,此函式支援了此功能,可用于读取 KRS-786/788HV 及 KRS-4012/4014HV 伺服机的实际位置。
使用注意事项:
- 呼叫此函式前,需先确认所有伺服机皆处于脱力状态,此函式才会有作用;若尚有伺服机处于出力状态,应先呼叫 Servo 类别的 release() 函式让伺服机脱力。
- KONDO 伺服机的讯号线需接上提升电阻,86Duino 才能读取到其回传的位置,请参考 KONDO 伺服机接线范例。
语法
myframe.capture(servo)
参数
myframe:ServoFrameKondo 型别的物件。
servo:Servo 型别的物件。
回传
KONDO 伺服机回传的当前位置。如果读取失败,则回传 0。
范例
#include <Servo86.h>
Servo myservo0;
Servo myservo1;
Servo myservo2;
ServoFrameKondo myframe;
void setup()
{
myservo0.attach(9);
myservo1.attach(11);
myservo2.attach(5);
// 读取 myservo0、myservo1、myservo2 的当前位置
myframe.positions[0] = myframe.capture(myservo0);
myframe.positions[1] = myframe.capture(myservo1);
myframe.positions[2] = myframe.capture(myservo2);
Serial.println(myframe.positions[0]);
Serial.println(myframe.positions[1]);
Serial.println(myframe.positions[2]);
myframe.save("captured_frame.txt");
}
void loop() {}
See also
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.
