How does a Rotary Encoder work without connecting it to 5V
They're just mechanical contacts.







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. Encoder wired to micro-controller with internal pull-ups.

The encoder is probably wired as shown (but I don't know why there are five wires on your diagram). What you can't see is that the internal pull-up resistors in the Arduino have to be enabled for this to work.