# Measuring distance IR

Hey, guys.
Can i measure distance between 2 diodes one emitting other receiving.
Sketch is something like TV IR remote control but with distance measuring not commands. (2m max distance)

No.

tedo3637:
Hey, guys.
Can i measure distance between 2 diodes one emitting other receiving.
Sketch is something like TV IR remote control but with distance measuring not commands. (2m max distance)

Technically you can but the smallest measurable period of time that you can measure with most of the Arduino boards is a microsecond which is 1 e-6 which is a millionth of a second.
IR is a kind of light that you can't see, the speed of light is constant and it's 299 792 458 m/s.
if you would put those numbers in the equation d=v*t the time period would be a microsecond, the speed is the speed of light and you get that the shortest length that you can measure with this method is 299.8 meters.
consider that the IR LED can't illuminate that much distance and you get that this method is useless, you need either a better timing or a stronger LED, this method used at radars just instead of an IR light beam they use an electromagnetic wave.
But if you want a good and cheap way to measure distances I would recommend using a sonar and not a makeshift radar because the speed of sound is much slower than the speed of light.
Consider buying the HC-SR04 sensor which is a good and reliable sonar module.
Just as a side note:
if you want to measure that way length of 2 meters like you wanted you would need a precision of 6.5 nanoseconds which is something unrealistic.

Okay,@dindibo4 can you tell me a method to make this, i need to create a small device(with not constant position) and i want to get position of this device.

Let me sketch, if we have 1 square flat surface and we set non-constant point in this square, we need to get position of this, and the connection from device and surface is wireless

tedo3637:
Okay,@dindibo4 can you tell me a method to make this, i need to create a small device(with not constant position) and i want to get position of this device.

Let me sketch, if we have 1 square flat surface and we set non-constant point in this square, we need to get position of this, and the connection from device and surface is wireless

Alright, if you want to measure a distance between a sensor and something else that is standing in front of the sensor I would recommend you using an active sonar that as I said it can be made easily with the HC-SR04,
It's a cheap sonar module that you can connect to the arduino.
It works a bit different than what you described, how it works is by sending an ultra-sonic soundwave which is above 20KHz and you cannot hear that and when it collides with something it bounces off the object and then goes back to a microphone that can detect this Ultrasonic sound.
The equation for this method is a bit different than the other equation, it's d = (v*t) / 2, the speed of sound, in that case, is 340.29 m/s at sea level and you divide all by 2 because the sound wave has to go from the sensor to the object and from the object to the sensor.
You can use this sketch

pin 2 - Is the pin that turns from LOW to HIGH as soon as the sound wave received.
pin 4 - The trigger pin the one that you control the speaker with and when it turns to HIGH it send the sound wave.

But if I understood you correctly you want to know the position of the device(the arduino board), if so that's something completely different, you would need a GPS module.
If you wanna know more about the sensors they called:
HC-SR04 which is the sonar module.
and the NEO-7M, which is a relatively cheap GPS module that compatible with the arduino.