Protect PC817 Optocoupler Anode from High Voltage
Like a 'normal' LED, the LED of an optocoupler is not controlled by voltage but by current.

With the 1 kΩ resistor as shown, and with a LED forward voltage of about 1 V, the current through the LED would be between approximately 9 mA and 27 mA; the absolute maximum rating of the PC817 is 50 mA, so this would still be allowed.

However, that's still a lot of current, and might load the output connected to IN3 too much. Consider increasing R13 to 2.2 kΩ or 4.7 kΩ.
(It would also be possible to replace R13 with a constant current source.)

You need a pull-up resistor at pin 4. This can be either an external one, or an internal one in the µC.
The value of the pull-up is determined by the CTR of the optocoupler; in the worst case, this is 50 % at the specified input current of 5 mA, and less at other LED currents. So assuming that less than 1 mA comes through the optocoupler's output, and that the µC runs at 5 V, the pull-up should be at least 10 kΩ.