WIRING of KY-040 Rotary Encoder plus Demo Code

Hi guys! Today I found in mailbox the encoder KY040 from China.

So I found this thread and copy/paste original code.
I found out that when you turn the encoder, Arduino always skip one step. That really irritates me.

So I must little bit change base code from first post.
I change interrupt mode from FALLING to CHANGE

  attachInterrupt (0,isr0,CHANGE);

modify isr routine

void isr0 ()  {
  up = (digitalRead(PinCLK) == digitalRead(PinDT));
  TurnDetected = true;
}

and correct little bug.

  if (!(digitalRead(PinSW)) && (Position != 0)) {

I haven't found a 0,47 uF capacitor, but with 1 uF it's working fine. Without bouncing.
Add one capacitor on the SW pin too.