can i use the ultrusonic ranger to calculate the angle?

kindly.,i have srf08 ultrusonic ranger ...i can calculate the distance by the example of srf08 ....i want to calculate the angle it possable or not? there is any code for that?

It depends what angle you are trying to measure.

The sensor will only measure distance directly, but as Trigonometry tells us, we can use a distance to calculate an angle. Mount the sensor on the inside of the angle looking at the other side in such a way so that as the angle changes the distance it will read changes to. Then the tangent of the angle will be equal to the distance read by the sensor divided by the distance between the sensor and the pivot point.

So angle = arctan(sensor distance / distance from sensor to pivot)

Note also that these sensors usually have trouble with smooth angled targets. They tend to reflect the sound off at an angle and so the senor won't see the target at all. If this happens try covering the target in something soft or irregular like carpet.

If this setup won't work, the classic way to measure angle is with a potentiometer.

We don't like cross posters around here:-