Hi everyone (or everybody I don't know^^)!
First, I'm sorry for my bad English because I'm French. But normally you will understand myself^^.
I'm new on the forum and also in the Arduino World. I just have one or two knowledges in the electronic.
I would like to build a simple robot which will be able to detect the objects in front of him and avoid them.
So, I would like you to explain me how to use a Sharp IR sensor.
In fact, I found how to do this but it doesn't work properly and I don't understand the code. How to choose the distance from the objects to avoid? Because with this code :
/* This is a simple code that reads an input from an analog pin on the Arduino and relays it back to the computer */
int irReader = 1; // the analog input pin for the ir reader
int irVal = 0; // stores value from Ir reader
void setup() {
Serial.begin(9600); // begins serial communication with the computer
}
void loop() {
irVal = analogRead(irReader); // read the value from the ir sensor
Serial.println(irVal); // sends ir val to computer
}
The values change only when my hand is between 10 and 15 cm. But in theory, this sensor (SHARP™ "GP2Y0A02YK") is supposed to detect 20 to 150 cm. Here is his datasheet : http://www.sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y0a02_e.pdf
Thanks in advance for your help.
PS : If you need some more informations don't hesitate to ask me! I hope you understood my topic...
PS 2 : I have an official Arduino uno. The positive of the sensor is on the 5.5V on Arduino, The negative on de GND of Arduino and the Vo on the pin analog 1 on arduino.