I am new to arduino and I would be happy if you help me read the value of a photoelectric sensor. For a university project we are planning to buy this sensor: http://www.produktinfo.conrad.com/datenblaetter/150000-174999/155921-da-01-ml-REFLEX_LICHTSCHR_SN_2000MM_de_en_fr.pdf
and supply it with 24V. We want to read the analog signal from the sensor using analog pin A0. The problem is that the analog input pin voltage should be limited to 5V. So I thought of a voltage divider but I have no experience with it. Could you please take a look at the attached photo and tell me whether it will work?
You have drawn the sensor with three wires, red, blue and black. I think you have exchanged the blue and black. According to the datasheet, the blue wire of the sensor is the GND and the black wire is the output signal.
The Arduino GND must be connected to the sensor GND.
Why do you use 24V, the sensor will probably run fine with 12V.
I think the sensor outputs a digial signal, therefor you need a digital input.
The 2k2 and 10k is okay. You may use higher values.
The Arduino Uno requires at least 3.0V for a good solid digital HIGH signal.
Edit: I had my calculations for the voltage divider wrong, that is removed now.
Proximity sensors are normally just that - on when object close or off when not, or vice versa - it doesn't provide an analogue output.
Get a meter on the output, check if 0-V or 24-V (industrial stuff quite often has offset outputs like 1 - 5 volts to detect faults).
A voltage divider would be fine to drop 24-volts to 5-volts for one of the digital inputs, roughly one fifth e.g. 39k and 10k in the chain and tap off at the junction. Check it first before connecting to the Arduino, get it the wrong way round and goodbye digital input, and don't forget to ground both.