Encoder gives values only in one way

Did you look at the examples in the rotary encoder library? Why re-invent the wheel?