Link : https://github.com/mathertel/RotaryEn...
An encoder is an electrical mechanical device that converts linear or rotary displacement into digital or pulse signals.
As we rotate our encoder, the two output will change depending upon the position of the encoder. Which will generate square wave pulses.
The encoder has a disk with evenly spaced contact zones that are connected to the common pin C and two other separate contact pins A and B.
When encoder rotate the pins A and B make contact with the common pin and the two square wave output signals will be generated which are displaced at 90 degrees out of phase from each other.
when the disk rotates clock wise, the point A comes in contact with conductive segment first and after that point B comes in contact with conductive segment.
when the disk moves anticlockwise, point B comes in contact with conductive segment first and after that point A comes in contact with conductive segment.