SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By leo357leo
#97341
Are there any programs from arduino to infra red sensor to measure changes in distance.

Thanks
By riden
#97348
Depending upon the distances involved, Sharp makes a line of IR sensors that work well with the Arduino. SparkFun carries them (see SEN-08958 and related products). For the code, Google "Arduino Sharp IR".
By leo357leo
#97359
Ralph, thanks for the info. I just bought an arduino and I'm learning the sketch language. I "v been on a few websites on programming the infrared for distance measurement.My project is to have the sensor on a post about 2 feet in front of me and I want the sensor to tell me with a buzzer when I've moved away from the sensor by more than 2 inches. Firstly, do you think infrred or ultrasound would be the best sensor. And do you have any ideas or websites on programs for this job.
Thanks,Leo
By Michael J
#97377
Hi,

I remember the Sharp sensors come in 2 varieties. I cannot remember the exact ranges but they are something like 2 - 12 inches and 4 inches and up. The output is analog and non linear. You can create a lookup table to map from the result returned by your A2D to a distance. I've done this with pretty good results.

The ultrasonic sensors (depending exactly which ones you buy) return one pulse at the start of a measurement and another at the end. You are responsible for measuring the time and then dividing by the speed of sound. These are very accurate, but do not handle reflections well.

So it depends a bit on what you want. If you want really precise measurements and the object of interest has a nice perpendicular surface, go for the ultrasonic. If the surface may be at an odd angle to your sensor, go with the IR. Lastly, the IR sensors may be affected by bright light.

Good luck,
Michael Jamet
By leo357leo
#97415
Michael, thank you for the reply. I am probably reflecting off clothing, so I think the IR would be better. Do you have any clues on programming the arduino so it tells me that I've moved away from the sensor by say 2 inches? Also I need a remote device to start the sensing. Any Clues?

Thanks, Leo
By riden
#97497
Could you give us a little more information? What are the distances involved and what is the nature of the remote activation you need? Your answers will help zero in on approaches.

As mentioned before, either a Sharp IR sensor or an ultrasonic sensor should do the trick. These devices usually have an analog output (as Michael said), so you can use the analogRead() function that reports on the output of the sensor. I've played with both types of sensors and they are really easy to use.

For remote activation, I'd consider using a cheap IR remote and a IR detector (like products from Vishay or Sharp). These receivers are more reliable than simple ir detectors because they are able to extract the remote data modulated on the IR signal.
By leo357leo
#97532
Ralph, thank you for your reply. If you can send me a program to convert analog to distance I would appeciate that. The distances I'm talking about are standing in front of an IR sensor about 2 feet away, start the sensor by activating it , say a push-button on my belt; then I want the sensor to buzz when I have moved away from the sensor by 2 inches.

Thanks,Leo
By riden
#97632
Leo,

The more that I think about it, the more I believe that you will may want to take the ultrasonic sensor approach. My reasoning is that IR sensors work on detecting the amount of reflected light from the transmitter and that can vary widely based on the characteristics of the reflected surface. I suppose that a measurement could be made from a reference material (sheet of white paper, etc.) at 24" and 26" and then apply a conversion factor based on the reading of the actual material at the 24" starting location. It could be done and if you have a Sharp sensor, you could experiment with that idea. BTW, here is a link to information about Sharp IR Rangers.

Ultrasonic sensors work on the basis of time-of-flight. They are able to calculate exact distances based on the time it takes for a transmitted signal to leave the sensor, bounce off the target, and be detected by the sensor. The type of reflective material doesn't change the time involved, only the amplitude of the reflected signal. At 24" you shouldn't have any problems with any kind of material. Therefore, you will probably be up and running quicker using an ultrasonic solution. Have a look at the Maxbotics ultrasonic ranger products. You'll be spending about $8 - $9 more than the Sharp IR solution, but I think you will have fewer issues.

There are many sample programs for the Arduino for both types of sensors. Topeka, I mean Google, is your friend: Google Arduino Maxbotics and Google Arduino Sharp IR
By leo357leo
#97649
ralph, thanks for your advice. I actually found a program that changes the input from the IR sensor to distance units. I actually got it up and running yesterday. I want to remotely start the sensor, so I can start the program and stop the program remotely. The whole idea with my program is to notify me if I've moved more than say 2 inches in a particular athletic move. I want to repeat the athletic move several times, and have the ability to determine if I have moved more than 2 inches each time. Any hints on programming for this job? I would like a buzzer to notify me if I have moved more than 2 inches from the initial read for that that particular move.

Thanks,Leo
By riden
#97698
Could you do something where you step up to your device and then do your move? That way the sensor would be reading all the time and when you get at the desired distance for n number of seconds, the measurement begins. Step away and the device disables itself.

Otherwise, I go the IR detector route and have it wake up the Arduino.

BTW, congratulations on your progress thus far.