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.