Added support for rotary encoder

-Also minor changes in main.c