An optoelectronic sensor comprising - at least one light emitting diode light source or semiconductor laser light source for transmitting transmitted light through a transmission aperture into a monitored zone, wherein the light source comprises a semiconductor crystal having a plurality of light source segments (18, 30) which are individually controllable and which are arranged in a lateral pattern; - at least one light receiver for detecting received signals which leave the monitored zone; and - a control device which is connected to the at least one light receiver and to the plurality of light source segments (18, 30) to individually control the light source segments (18, 30) for their operation and to evaluate received signals of the light receiver, characterized in that the control device has a setting mode and an operating mode and (i) activates the light source segments (18, 30) one after the other in the setting mode and evaluates the respective received signal obtained in so doing with respect to its strength in each case and (ii), in the operating mode, activates those light source segments (18, 30) with which the received signal has a strength above a predefined threshold in the setting mode in order to carry out a self-alignment between the light source and the light receiver; or activates a plurality of light source segments (18, 30) for simultaneous operation which are selected such that the sum of the received signals measured in the setting mode and corresponding to the selected light source segments lies above a predefined threshold in order to carry out a self-alignment between the light source and the light receiver. - at least one light emitting diode light source or semiconductor laser light source for transmitting transmitted light through a transmission aperture into a monitored zone, wherein the light source comprises a semiconductor crystal having a plurality of light source segments (18, 30) which are individually controllable and which are arranged in a lateral pattern; - at least one light receiver for detecting received signals which leave the monitored zone; and - a control device which is connected to the at least one light receiver and to the plurality of light source segments (18, 30) to individually control the light source segments (18, 30) for their operation and to evaluate received signals of the light receiver, characterized in that the control device has a setting mode and an operating mode and (i) activates the light source segments (18, 30) one after the other in the setting mode and evaluates the respective received signal obtained in so doing with respect to its strength in each case and (ii), in the operating mode, activates those light source segments (18, 30) with which the received signal has a strength above a predefined threshold in the setting mode in order to carry out a self-alignment between the light source and the light receiver; or activates a plurality of light source segments (18, 30) for simultaneous operation which are selected such that the sum of the received signals measured in the setting mode and corresponding to the selected light source segments lies above a predefined threshold in order to carry out a self-alignment between the light source and the light receiver.