Here is a write-up I did to explain how rotary encoders can be hooked up to an AVR microcontroller system.
Example code:
encoder.c