indexRead()

描述

回传 Z 针脚上的电位。此函式只可在 Pulse/DIR、CW/CCW、A/B Pulse 工作模式下使用。

语法


Enc0.indexRead()
Enc1.indexRead()
Enc2.indexRead()
Enc3.indexRead()

参数

Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。

回传

LOWHIGH

范例

#include <Encoder.h>

void setup() {
  Serial.begin(9600);
  Enc0.begin(MODE_AB_PHASE);
}

void loop() {
  Serial.println(Enc0.indexRead()); // 印出 Z pin 上的电位
  delay(100);
}

See also

begin()
setIndexReset()


函式库参考主页面

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.