In this tutorial we will learn about the different types of Rotary Encoders and how it works. We will also interface KY-040 rotary encoder with PIC Microcontroller PIC16F877A and control the value of an integer by rotating the Encoder.