Sharp GP2Y0D810Z0F how to use?

Hi.

I bought a IR-Distance Sensor (Sharp GP2Y0D810Z0F), how can I use it? The data sheet says the operating voltage is 4,8 - 6V, my Arduino Uno has got 5V output, but some people I've seen are using a resistor for it, is that needed?

And another question: How can I read out the distance and print it on the screen (i've seen a java like output-console, how can I use that?)

Thank you!

I bought a IR-Distance Sensor (Sharp GP2Y0D810Z0F),

A link is worth, well maybe not a thousand, but certainly a bunch.

how can I use it?

Connect it to some pins and write some code.

The data sheet says the operating voltage is 4,8 - 6V, my Arduino Uno has got 5V output,

Perfect.

but some people I've seen are using a resistor for it, is that needed?

Yes. No, wait, no. No, wait, we need a link to the data sheet.

How can I read out the distance and print it on the screen (i've seen a java like output-console, how can I use that?)

We need to see the data sheet to answer part 1. Serial.print() for part 2. No idea what "java-like" console you are talking about.

Java is a programming language. How can a console window be java-like? That would be like being C++-like or C#-like or VB-like.

http://ieee.ucsd.edu/wiki/_media/projects/micromouse/gp2y0d810z0f.pdf

Thats the data-sheet.

So the question is how can I work with the values? What signal is the sensor giving out when it detects a object? "HIGH" or "LOW"?

I tried this:

int sensorPin = A0;    
int sensorValue = 0;

void setup() {
    Serial.begin(9600);
}

void loop() {

  sensorValue = analogRead(sensorPin);    
   
Serial.println(sensorValue);
delay(1000);

it just gives me random numbers between 0 and 1000..... what should i do?

Thanks

Have you seen this: http://www.dfrobot.com/wiki/index.php?title=DFRobot_Infrared_sensor_breakout_%28SKU:SEN0042%29

Thanks, I solved the problem with putting out the resistor :D

I'm now able to check if there is an object with an if condition.

But I've one more question: what's the difference between the digital and the analog pins? I learned that I should put the IR_Sensor into an analog pin, but the picture from the link you wrote showed that I should use a digital pin.

Thanks!

A digital pin reads HIGH or LOW. That sensor seems to detect, or not, an edge. So, either there is an edge (HIGH) or there isn't (LOW) (the actual values may be the other way around).

An analog pin measure a range of voltages, such as those from a potentiometer, and outputs a value between 0 and 1023 that corresponds to where in the 0 to 5V range the measured value falls.

Ah ok, thanks! I connected the sensor with an analog pin (A0) but I was able to read the "edge" out with "digitalRead", how is that possible? :D

Sorry for my bad english :(

Thanks!

I connected the sensor with an analog pin (A0) but I was able to read the “edge” out with “digitalRead”, how is that possible?

The analog pins, 0 to 5, can be used as digital pins, with different number (14 to 19 on the 328-based Arduinos). The A0 string is #defined to have the correct value (14 for a 328-based Arduino, 54 on a Mega) on any Arduino.