[Resolved]Build a Simple Robot!

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.

up

I really need to find how to do it...

I really need to find how to do it...

Some reading material:

http://www.google.com/search?hl=en&as_q=Sharp+IR+sensor&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Farduino.cc%2Fforum%2Findex.php&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=

In fact, I found how to do this but it doesn't work properly and I don't understand the code.

The code does indeed work. What it does, and what you expect it to do are most likely not the same thing. What either one of those things is is a mystery, though.

Thank you very much for your answers.

@zoomkat, I already search a lot of informations but nobody have a project that my mine.

@PaulS, In fact, I want my robot to detect the objects in front of him about 100 cm. And if he detect it, it moves back (for the moment^^).

But in the internet I don't find how to chose the detection distance.

More reading material.

http://www.google.com/search?hl=en&as_q=robot+object+avoid&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=

Yes but, how to chose the detection distance with the Sharp IR sensor? That's the question...

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.

Perhaps you did not read/understand from the data sheet that the 20 to 150 cm specification is for a very reflective piece of white paper and not for a hand, which does not reflect the IR as well as the white paper.

SO, it will be annoying to avoid objects no? If the detection distance is random it will be not very good. Do you think a sensor of ultrasounds would be better for this project?

Do you think a sensor of ultrasounds would be better for this project?

Much better.

Ok. Thanks for your answer. I write resolved in the topic title^^.