Sensor Input on arduino uno shows 0 volt

hello friends

i m working on a projeCt which i have to enter and 5 volt input into the pin number 12 (Digital)

so that i can count the number of times that sensor sensed something

i used this code : pinMode(SensorStatePin,OUTPUT);

but when i plug in the 5 volt wire into the pn 12 it only shows 0 volt !!

its driving me crazyy

i hope that some body could help me with that

THANK YOU IN ADVANCE :slight_smile:

i have to mention that its an pnp sensor . should i use a resistance in the way of input or not ?

I'm almost as confused as you are.
You say you want to detect 5volt of a PNP sensor with pin12.
And then you configure pin12 as an output.

Post a link to the sensor.
Post a diagram of how you have connected it. With all the voltages and parts values.
Tell us which Arduino you're using.
Post your full code.
We are not mind readers.
Leo..

im using this PNP sensor : http://omronkft.hu/pdf_en/e3x_na.pdf

and i set it as output because i wanted to apply 5 volt to pin number 12 and if you want to apply 5 volt you

need to set the pin as output to work as an pulldown pin .

im using arduino uno

should i change the pin to input ? because if i do that i cant apply 5 volt to my digital pin anymore ...

i hope i answered all your questions

THANKS

A PNP sensor outputs (sources) voltage that you can read with an Arduino input.

A PNP sensor outputs almost the same voltage as the sensor's supply.
So if you power the sensor from 12volt, almost 12volt is coming out of the sensor's output (when activated).

That (12volt) is dangerous for an Arduino pin, so you have to use a voltage divider to cut that to <=5volt.
If your sensor runs on 12volt, use the diagram from post#14 in this recent thread.
https://forum.arduino.cc/index.php?topic=400763.0
Leo..