capture()

描述

讀取指定 KONDO 伺服機的當前位置。

KONDO 的 RC 伺服機提供了回傳當前位置的特殊功能,此函式支援了此功能,可用於讀取 KRS-786/788HV 及 KRS-4012/4014HV 伺服機的實際位置。

使用注意事項:

  1. 呼叫此函式前,需先確認所有伺服機皆處於脫力狀態,此函式才會有作用;若尚有伺服機處於出力狀態,應先呼叫 Servo 類別的 release() 函式讓伺服機脫力。
  2. KONDO 伺服機的訊號線需接上提升電阻,86Duino 才能讀取到其回傳的位置,請參考 KONDO 伺服機接線範例

語法


myframe.capture(servo)

參數

myframeServoFrameKondo 型別的物件。

servoServo 型別的物件。

回傳

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

positions[]
save()


函式庫參考主頁面

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.