Doubt Regarding Encoder

Any small signal NPN transistor will work here.

Use your multimeter to check actual signal levels, and make sure all connections are sound (if using solderless breadboard that's not always the case).