The D4 pin is in input mode and probably with a pull up resistor. So... If you have a high impedance volt meter... You should measure 5 volts there.
You need to connect the servo power jumper to a voltage source. Probably the RAMPS board can power your optical sensor so jumping the +5 to VCC will probably give you power on the D4 connector.
You need to connect the servo power jumper to a voltage source. Probably the RAMPS board can power your optical sensor so jumping the +5 to VCC will probably give you power on the D4 connector.