Introduction: RGB Rotary Encoder Example (ATmega328, AVR)
The above setup uses interrupt service routines (ISRs) to interpret a rotary encoder. The specific rotary encoder used also contains an RGB LED, which is driven by PWM. There is a video in the full article.
Here is a link to the full article: http://0xfebytes.blogspot.com/2013/08/rgb-rotary-encoder-with-pwm-and-isrs.html