Go Down

Topic: Detecting distance with IR Sensor (Read 311 times) previous topic - next topic

tjb2of3

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?

knut_ny

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

Robin2

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

...R

tjb2of3

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?

knut_ny

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)
Ny

JimboZA

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  8) 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.
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Go Up