The proximity switch can work for a wide range of power, from 8v to 18v DC, D3 protects reverse power supply connections, and U1 regulates the supply to +5v , -5v is derived from U2 555 oscillator which serves dual purpose.
Part of – InfraRed LED Flasher for Optical Switch
The infra red diode D2 detector gets the reflected light from LED and some ambient light, The forward voltage drop of D2 will vary with the amount of light falling on it. Ambient light causes a DC component and the pulsing light from D1 causes an AC component.
The capacitor C6 blocks DC and only transfers AC pulses if any to opamp amplifier U3A whose gain is set by R18, D9 rectifies the pulses to DC and this DC voltage is used by opamp comparator U3B which drives Q1 through Q2 for an open collector output for relays. LED D7 turns on when relay Output is high.