WIRING of KY-040 Rotary Encoder plus Demo Code

I'm using this encoder and I'm getting really imprecise values.