interfacing encoder to arduino

michinyon:
I've seen it recommended, that the variable accessed in the interrupt routine should be declared "volatile", although whether it matters in this case, I don't know.

If a variable is used both in an interrupt routine and in the rest of the sketch you make it volatile - otherwise
the compiler might do the wrong thing.