ENCA and ENCB to GPIO with internal/external pull-up. Also, some capacitors 100p-1n will be needed to prevent noise. Interrupt by ENCA fall down, reading state of ENCB. If 1, rotating cw, if 0, rotating ccw. That's all. Very easy.
Thank you EasyRider but in the above mentioned encoder what pins I have to use for signals ? DT and CLK ? I am using them SW is I think for press detection. But neither is working. The module has the required resistors and capacitors.
Your code it totaly wrong, that what I mean. I told you how to work with encoders. There is no way to use pooling method. Interrupt only.
You can use this project as a reference. https://copy.com/onGZo4BMRetHiwnw