Connecting a light barrier (NPN or PNP) to an Arduino

Is your npn output an open collector output?
In that case you can put the load resistor on the 5V rail (instead of the 12 V rail and read the signal from the grey cable).