Pages: [1]   Go Down
Author Topic: Detecting distance with IR Sensor  (Read 251 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone, to start off I'm new to the forums and to arduino in general.  I've done a quick search for relevant topics but haven't been able to answer my own question, so here goes:

My goal is to detect changes in distance with an Infrared sensor, and if the distance changes over a period of ~1 minute, to turn on an LED.  Ideally, I would be able to connect ~10 sensors, each connected to its own light.  In practice, my operation would look like this:
1) position materials
2) zero the sensors
3) run system for about  a minute.  Lights would indicate a change in distance read by the sensor over this time interval.

I know this is a general explanation, but I'm just trying to figure out if it's even possible at this point.  I can provide more info if you need it.  Does this seem like a feasible idea?
Logged

Narvik, Norway
Offline Offline
God Member
*****
Karma: 22
Posts: 968
electronics engineer, teacher.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

make a simple sketch..   It is not very clear to me how you actually think....
Be more spesific about IR-sensor
Logged

Ny

UK
Offline Offline
Faraday Member
**
Karma: 101
Posts: 6211
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are plenty of posts here about measuring distances with sonar. But isn't light just too fast?

...R
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, sorry again about the vagueness. I attached a simple diagram.  Basically, I want to be able to zero the sensor at time t1, so that it will use the distance d1 as "zero".  Over the time interval t1 - t2, the sensor will be continuously measuring the distance d.  If that distance changes at any time over that interval (so that d2 > d1), I want the controller to turn on an LED.

The sensor I'm looking at is this: http://www.acroname.com/products/R146-GP2D120.html
My understanding is that it continuously measures distance, and the output signal is a voltage which relates to that distance. 

So my questions are: (1) Can I hook up this sensor to an arduino, and will it properly read the voltage output from the sensor? (2) Can I code the controller so that if there is any deviation in that voltage, a light will be switched on?


* Sensor Diagram.png (5.7 KB, 471x363 - viewed 10 times.)
Logged

Narvik, Norway
Offline Offline
God Member
*****
Karma: 22
Posts: 968
electronics engineer, teacher.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you've got what the datasheet tells - surely this connects directly to an analog input
(maybe a tiny cap can remove ripple)
You will with ease detect changes below 20cm (maybe as small changes as 1mm)
If you plot points into excel, you might find a handy formula for distance. (or use a lookup-table)
Logged

Ny

Online Online
Faraday Member
**
Karma: 80
Posts: 3797
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you Google that part number + Arduino you'll probably find some code.

Meantime look at this example which reads the output from a potentiometer on an analog pin. That's essentially what you need to do with the sensor: the yellow wire is the same as the pot's middle wire, in that it outputs a voltage.

Then have a look at the world famous  smiley-cool and oft-quoted Blink Without Delay to see how to repeatedly do something. In your case, every second or whatever, read the sensor. Compare the value with the previous one (which you would have saved) and act accordingly.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Pages: [1]   Go Up
Jump to: