Interfacing of Proximity Sensor with Arduino
As you can see from the datasheet this sensor uses a NPN ON/OFF output 



A simple pull-up resistor and a digital input is needed. You need to supply the sensor with a 12 to 24V voltage







simulate this circuit &ndash; Schematic created using CircuitLab

You don't need any starter code, just use the code for digital read , reading LOW  meaning proximity detected.