directionRead()
Description
Function to get the rotating direction of optical encoders or the moving direction of rotary
Note: this function is available after the “Coding 105” and just works under Pulse/DIR, CW/CCW and A/B Pulse mode.
Syntax
Enc0.directionRead()
Enc1.directionRead()
Enc2.directionRead()
Enc3.directionRead()
Parameters
None
Returns
1:the value of counter is increasing.
-1:the value of counter is decreasing.
Example
#include "Encoder.h" void setup() { Serial.begin(9600); Enc0.begin(MODE_AB_PHASE); } void loop() { Serial.print("count = "); Serial.print(Enc0.read()); // read the counter value Serial.print(" "); Serial.print("dir = "); Serial.print(Enc0.directionRead()); // print the rotating direction 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.