Pages: [1]   Go Down
Author Topic: [Resolved]Build a Simple Robot!  (Read 771 times)
0 Members and 1 Guest are viewing this topic.
Le Havre
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :

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.
« Last Edit: May 01, 2012, 08:37:52 am by SauvalDanny » Logged

Le Havre
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

up

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

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8913
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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=
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46032
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Le Havre
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8913
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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=
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Le Havre
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8913
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

« Last Edit: April 27, 2012, 04:59:07 am by zoomkat » Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Le Havre
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46032
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you think a sensor of ultrasounds would be better for this project?
Much better.
Logged

Le Havre
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: