views:

666

answers:

2

How can I use the accelerometer feature in the iPhone to calculate distances while walking?

+1  A: 

It would probably make more sense to use Core Location for this.

In fact, a sample app to calculate walking distance and speed is created in chapter 24 "iPhone Location API" of iPhone SDK Development by Bill Dudney and Chris Adamson.

gerry3
That would be ideal if possible, but it assumes that you have an iPhone and not an iPod Touch with no GPS.
Nimrod
Core Location is available on all devices, but obviously a device with GPS may be preferred or required depending on the app.
gerry3
+1  A: 

You can't use the accelerometer to determine distance.

If I'm at rest, the accelerometer detects only acceleration due to gravity. This obviously set the walking distance to 0.

But if I'm walking at constant velocity, and start your app while walking, my acceleration is also zero, thus the accelerometer detects only acceleration due to gravity again. The situation is same as above, and the walking distance is 0, which is incorrect.

Not to mention the difficulty in dealing with changes of acceleration due to the orientation of the device.

You need Core Location to compute anything related to distance. You can use the accelerometer to implement a pedometer but that only counts steps, not distance.

KennyTM
hey i got the logic . after getting the acceleration vectors.we can check it by a certain threshold value which we set. and if it match or near about. the count is incremented.then we indirectly get the step count.then step count*stride lenght=distance travelled.
Actually you can. You need to integrate the acceleration twice to get the position (accel => velocity => position). I have done this using the Wii Remote (!) and it works, but you need a very controlled environment. Any bumps or shakes messes it up completely.
Martin Wickman