check my lib - Lightweight Arduino Library for Rotary Encoder - #9 by enjoyneering - Sensors - Arduino Forum