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?)
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.
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.
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.