Many thanks, worked immediately : )
Good, I'm glad you got it working, but will you know how to do this on a different opto-coupler?
Looking at the internal schematic will give you an idea of how to connect it up. Refer to page 5 of the data sheet.
https://www.mouser.co.uk/datasheet/2/187/Pg_382-1139354.pdfAll of the emitters on the left hand side are just IR LEDs, so all that's needed is a series resistor, as you've correctly figured out.
The part you have ends in a 1, so has an open collector output, i.e. a single transistor which connects the output to 0V, when activated. A resistor is required to enable the output to be pulled up to 5V or whatever the desired output voltage is, which can be up to 15V. Note that the output transistor performs an inverting function and there's an inverting logic gate before it, so when the sensor is illuminated, the output will he logic level high.
The other part number ending in a 3 also has an open collector output, but it has a non-inverting buffer before it, so will have the reverse logic function i.e. detector illuminated: output logic level low.
Part numbers ending in 4 and 5 have the 10k pull-up resistor built-in along with a protection diode, to prevent the output voltage from exceeding the supply voltage, by more than 0.6V. Again note the inverting and non-inverting logic gates. All that's needed is the detector to be powered: no external resistor is required.
Part numbers ending in 0 and 2 have totem pole outputs. Another transistor is added to pull the output voltage up and a diode drops the voltage a bit.
So why have all these options?
Obviously having a choice between inverting and non-inverting output can simplify the design of the logic circuit.
Open collector outputs can be just connected in parallel and the one which goes low, will take the entire line low, this acting as an OR function. Again this can simplify designing the logic circuit.
Sometimes having to use an external 10k pull-up is good because it can be connected to a higher or lower supply voltage, such as 12V, thus enabling it to interface with higher or lower voltage logic. On the other hand a built-in pull-up resistor can be handy to save space.
The totem pole output will drop be at least two diode drops below the supply voltage, but it will be able to source more current, than an open collector output and 10k pull-up resistor. They're better at driving long cables, which will have some capacitance and the lower output voltage means they can normally drive 3.3V logic gates, with no additional components.