directionRead()
描述
注意:從 86Duino Coding 105 版本以後才能使用這個函式,並且只可在 Pulse/DIR、CW/CCW、A/B Pulse 工作模式下使用。
語法
Enc0.directionRead()
Enc1.directionRead()
Enc2.directionRead()
Enc3.directionRead()
參數
無
回傳
1:正轉(即計數器的值正在遞增)
-1:反轉(即內部計數器的值正在遞減)
範例
#include "Encoder.h" void setup() { Serial.begin(9600); Enc0.begin(MODE_AB_PHASE); } void loop() { Serial.print("count = "); Serial.print(Enc0.read()); // 讀取編碼器的計數值 Serial.print(" "); Serial.print("dir = "); Serial.print(Enc0.directionRead()); // 印出旋轉或移動的方向 delay(100); }
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.