Photoelectric sensor

Hi everyone,

I am doing a project that use arduino uno to switch on and off a photoelectric sensor. How do i test the current of the output signal black wire as i worry that the arduino can only take in 5V and 40mA. I have connected the brown to 18V power supply, blue to collector of transistor and 5V supply to the base transistor.

Components used:
NPN photoelectric sensor
supply voltage 10-30V
output current <100mA
power consumption <20mA
NPN Transistor 2n3904

blue to collector of transistor and 5V supply to the base transistor.

This is probably wrong and would destroy the transistor.

Post a link to the data sheet or product page of the sensor.

If the sensor output is "NPN open collector" you can just use INPUT_PULLUP on the Arduino input pin.

If the sensor's output is PNP type, you'll need to at least use a voltage divider, or something a bit more complex.

What is the link to or the part# for your sensor?
How long would be the cable to the Arduino?

Example circuit for a PNP type photoelectric sensor:

The 4N35 component in the above is an optocoupler. Very useful, especially if you are a bit unsure about "stuff". Guide to optocouplers at www.arunet.co.uk/tkboyd/ec/ec1optoiso.htm