Can anyone let me know how to connect the slotted optical sensor (any brand and any series)? Because I do not know how to connect it. Do you have its circuit connection diagram? Thank you first for your kind help.
If it is marked "E" on one side and "D" on the other, you're off to a start. The "E" is for emitter. The leads should be marked + & - so you know the applied voltage polarity. The emitter is an irled, which is happy with abour 50 mills current. Divide your voltage source by .05 for the current limiting resistor value. Use the next larger value in the standard series.
The Detector side may have 3 leads. Use a meter to find the base lead - it's the one that shows a pn junction to the collector and emitter. Don't use it. Put the emitter to ground and the collector to a voltage source through a fairly large value resistor - say 50K to +12 volts. You get very little current out of a phototransistor, but using a big resistor should let the output swing from Vcc to ground.
You usually need at least one more transistor to get enough power out of the setup to do any useful switching.