Moving phone forward and backward

Is there a sensor that can detect the moving of my phone forward and backward and measure velocity?

Thanks, but the orientation sensor assumes that the device itself is not moving, and the accelerometer sensor detect shaking and measure acceleration when tilting the phone. I want my phone to move forward and backward on a flat table, and measure if it moves backward or forward (I don't want to measure the tilt).

The acceleration of the phone in the x and y plane of the table is felt by the phone as tilts momentarily,as per relativity theory, right?
You can test this with a clock timer and the graph component.
Now all you need is to establish baseline stationary values then integrate acceleration over time to get velocity, then integrate velocity over time to get displacement.

No, I have not done this yet.

1 Like

I made a rudimentary program that "integrates" acceleration for velocity (assuming that v at t = 0 is 0):
velocity_from_accelerometer (2).aia (3.0 KB)

It takes the sum of the acceleration for 100ms, and multiplies it into the time period (again, 100ms), which gives the average velocity in that period of time.

I also subtract g (acceleration due to gravity) from aₓ (vertical acceleration component).

1 Like

As pointed out by two Power Users, my integration method will rapidly lose accuracy.

Maybe consider hiding magnets under the table, or using the phone Camera to simulate an optical mouse over a specially printed table top, perhaps by local color detection?