Optical Laser sensor

Hello

I have 1 question

I have and optical laser sensor which I would like to use using arduino UNO
THe logic of it is if it gets the signal back there is no object between ...and if it doesnt get the signal back there is an object between.
It uses from 10-30VDC...I am powering it with 12V
I would just like to know how should I wire it and the code to use it ... just that the code tells me if there is an object between the sensor and reflecting glass.

The sensor with glass:

The wires:

The schematics of the wiring

Please post a link to the exact model sensor that you have. There are several variations.

The picture shows an IR reflection beam break sensor.

Measure if there is any voltage on the output wire in both situations (beam detected or not).
Then we know if you have the NPN or PNP version of the sensor.
Leo..

This is the link to the sensor

Its a PNP sensor.

https://www.balluff.com/en/de/productfinder/#?data=selection[ca]%3DA0001%26selection[cg]%3DG0103%26selection[product]%3DF01318%26selection[product_variant]%3DPV120959

You seem to have the PNP version of the sensor.
Use a voltage divider (two resistors) to drop the 10-12volt output from the sensor (on a 12volt supply) to <=5volt for the Arduino.
Try a 10k resistor between Arduino pin and ground, and a 15k resistor between Arduino pin and sensor output.
Connect sensor ground to Arduino ground.
Leo..

Wawa can you please tell me the schematics of the wiring based on the colors of my wires...
I have lost myself and dont really understand what you meant with the resistors.

Thanks
E

dont really understand what you meant with the resistors.

Look up "voltage divider". It is a simple, but extremely important circuit.

Yea I know what that is but I don't understand what he meant .... Like with the pins and stuff

Which "Arduino pin" do you intend to use to read the sensor output? That would be the pin in question.

If this is a problem, we strongly recommend that you work through the beginner tutorials, like how to blink an LED, read a pushbutton, read an analog voltage, etc.

Yea yea I know all of that...
I made my printer already and some other projects I just cant seem to get the right output from the sensor...

Then post a hand drawn wiring diagram and your code, using code tags.

Explain the problem as described in the "How to use this forum" post.

Hello
Let me explain this one more time what I am trying to tell you :slight_smile:
I have an optical sensor and I want to get output from it on the Arduino.
I just don't know how to wire the sensor and I just want the program to output if there is object in the way or not.

In the picture bellow I wrote what the output is being given to me.

I will be using it for my final exam and I'm kinda in hurry.

The code I wrote:

int IN_PIN = 9;
void setup()
{
pinMode(IN_PIN, INPUT);
Serial.begin(9600);
Serial.println("Starting Optical sketch");
}

void loop() {
digitalWrite(OUT_PIN, HIGH);
if (!digitalRead(IN_PIN))
{
Serial.println("No Object");
}
else
{
Serial.println("Object Between");
}
delay(500);
}

I will be using it for my final exam and I'm kinda in hurry.

Late start. Good luck with the exam.

well thank you but that comment wasn't really needed ...
And yea In hurry for the first review not the final test...

Was this comment "really needed"?

I will be using it for my final exam and I'm kinda in hurry.

We are volunteers interested in helping people learn. We are not impressed by your procrastination or deadline.

Ahh... well can someone just tell me how I should wire the sensor thats all I need ...
I am not asking for anything big I just need some info of that

The datasheet isn’t very helpful, other than telling you that you’ll need to do some probing to figure the output state under operating conditions.

The Q output of the sensor is what you’re looking for.
It probably swings between the two supply rails (or may be open-collector*).

If you measure between Q and 0V you’ll see the sensor changes.
If it’s pulled ‘high’, you’ll need that voltage divider to get down to 5V
If it’s an *open collector output (or equivalent), you’ll need to use INPUT_PULLUP, or an external +V biasing resistor to see the voltage swing.

Let us know what you discover.