Photoelectric sensor

HEllo

I need some help about how can I wiring output of my sensor to arduino
I have this sensor
http://pokit.org/get/?e5509e9832b396261b9f239bcfbab9ee.jpg

My supply of that sensor is 24VDC and output of sensor is 200mA
How can I made circuit for reading this output on my arduino input ?

Depends on which sensor you have.
The NPN or the PNP version.

Connecting the NPN model should be easy.
Just connect the open collector output to a digital input with INPUT_PULLUP enabled, and read the pin.
Dont forget to share grounds if you have different supplies.

The PNP version needs a voltage divider to drop the sensor output voltage to <5volt.

Sensor supply can be 10-30volt. So it could also be powered from a 12volt supply.
200mA means that the sensor can switch upto 200mA.
The sensor itself only uses 15mA.
Leo…

Wawa:
Depends on which sensor you have.
The NPN or the PNP version.

Connecting the NPN model should be easy.
Just connect the open collector output to a digital input with INPUT_PULLUP enabled, and read the pin.
Dont forget to share grounds if you have different supplies.

The PNP version needs a voltage divider to drop the sensor output voltage to <5volt.

Sensor supply can be 10-30volt. So it could also be powered from a 12volt supply.
200mA means that the sensor can switch upto 200mA.
The sensor itself only uses 15mA.
Leo…

have you any schematic for this .
I have npn photocell I build web guide system if you know what is this .

Wawa: Connecting the NPN model should be easy. Just connect the open collector output to a digital input with INPUT_PULLUP enabled, and read the pin. Leo..

Which part don't you understand.

I have npn photocell . I have problem when signal is LOW why I cant one of digital output set as HIGH,but When is signal HIGH i can it. I need this for controling direction dc motor . I switch on relays.

Reading a sensor and outputting the result to a motor or relay are two different things.

Read the sensor state, and make it turn the onboard pin13 LED on/off first. Then worry about relays and motors.

If you already have written code, post it. Leo..

Wawa: Reading a sensor and outputting the result to a motor or relay are two different things.

Read the sensor state, and make it turn the onboard pin13 LED on/off first. Then worry about relays and motors.

If you already have written code, post it. Leo..

void setup() { // initialize digital pin 13 as an output. pinMode(8, INPUT); pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() {

int state1=HIGH; digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

state1 = digitalRead(8);

if (state1 == LOW ){

digitalWrite(13,LOW);

} }

this is code but this code didnt work do you know why ?

Try this.

const int sensorPin = 8;
const int ledPin = 13;
boolean state1 = LOW; // state at startup

void setup() {
  pinMode(sensorPin, INPUT_PULLUP); // sensor input with internal pullup resistor enabled
  pinMode(ledPin, OUTPUT); // initialize digital pin 13 as an output.
}

void loop() {
  state1 = digitalRead(sensorPin);
  if (state1 == HIGH) {
    digitalWrite(ledPin, HIGH);
  }
  else {
    digitalWrite(ledPin, LOW);
  }
}

Hey this code really helped me with a project I'm working on with a Banner NPN Photoelectric sensor connecting to an Arduino. It took me a while to find the right answer, but it saved me posting a new topic when the answer was there to find.

Thanks!