Optical endoder gives two steps

outsider:
How is the encoder wired? Maybe you need to use pinMode(pin,INPUT_PULLUP) or a debounce library, or (last resort) interrupts.
Encoder Library, for Measuring Quadarature Encoded Position or Rotation Signals

Hi,

I ask for the physical wiring (i mean, has it some filtering, or pull up's, ...). May be the problem is a bounce ...

Regards