You can use acceleration values ββfrom the accelerometer to measure speed and distance. There is really good paper ( Implementing positioning algorithms using accelerometers ) that explains the errors you get from the accelerometer, and methods for getting speed and position from the acceleration value.
Some pseudo codes:
velocity[i] = (acceleration[i] + acceleration[i-1])/2 * interval + velocity[i-1] distance[i] = (velocity[i] + velocity[i-1])/2 * interval + distance[i-1]
interval is the time between acceleration/velocity[i] and acceleration/velocity[i-1] , which is related to the refresh rate of the accelerometer.
To increase accuracy, you should filter out acceleration values ββin forehand. I implemented such an algorithm on the iPhone 3GS and it worked very well. The accelerometer allows you to measure distances of 30 cm with an error of about 1 cm. I have not tested long distances.
source share