This example C code can be used to implement a completely interrupt driven rotary encoder counter (incremental type) using PIC16FXXX microcontrollers built-in timers and counters. This code was written in 2005 for a simple factory automation project I did. The code is written for HI-TECH PIC16 compilers. The microcontroller used was PIC16F877A. Note: This program supports only uni-directional counting. The encoder output should is connected to TMR1 module’s input pin (PORTC1).