A rotary encoder is a cleverly designed piece of hardware that finds use in every projects that require to sense the rotatory motion of some shaft, knob etc, to find the direction of rotation, angular velocity etc. There are many types of rotary encoders of which some are designed for specific advanced applications. But here we’ll be using one of the many types of rotary encoder called an incremental rotary encoder or quadrature encoder as it is sometimes called. It works by mechanical means.
If you want to know more about a rotary encoder and how it actually works, go to Dejan Nedelkovski‘s rotary encoder tutorial here. He has also published a well explained video tutorial of rotary encoder which can be found here on YouTube. Continue from here after you’ve done that because I’m not going to talk about how it works in detail.