You need a resistor wired up like this:
Arduino pin --- resistor --- Anode of optocoupler.
If the LED in the optocoupler has Vf of 1.6V, then the resistor needs to be:
(5V - 1.6)/20mA = 170 ohms
to limit the current to 20mA to prevent damaging the arduino pin or the LED.