How can I use the accelerometer feature in the iPhone to calculate distances while walking?
views:
666answers:
2It 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.
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.