Last semester, I used one rotary encoder as an input. So I want to sum up it that I used and learned.
These rotary encoders rotate all the way around continuously, and are divided up into 24 ‘segments’. Each segment has a click-y feeling to it, and each movement clockwise or counter-clockwise causes the two switches to open and close. There is no way to know what the current ‘position’ is – instead you would use a microcontroller to count how many ‘clicks’ left or right it has been turned. If you need to detect rotational ‘position’ a potentiometer would be a better choice. – Adafruit Description
There 3pins for encoder value and 2pins for push button.
I just looked at the working principle of the rotary encoder, I was impressed it.
Youtube – Encoder Working Principle Link
The disk has some kind of optical pattern, which is electronically decoded to generate position information. There are corresponding pairs of LED and phototransistors arranged so that the LED Light receives through the transparent sections of the rotor and detected by phototransistors on the other side.
Arduino Library (Link)