iPhone Accelerometer Code

As I mentioned in the comments over here, getting UIKit to give your app Accelerometer data is pretty straightforward. Here’s my sample code that combines the accelerometer howto from the standard iphone hello world app and Erica’s slider howto.

Note: Kroo from IRC warns that this technique will only work if the app is launched from launcher or the springboard.

Also: Drunknbass found that you may have to restart springboard before it will work.

And: Check out Erling’s code if you want a faster sample rate.

3 responses to “iPhone Accelerometer Code”

  1. Gordon says :

    I was wondering about this. How much power does running a simple app draw? Could you run one all the time? Specifically… since cell tower triangulation looks like a wash (public FCC database doesn’t have enough data points), I wonder how far you could get with an accelerometer and dead reckoning. (Set your location once, then the app keeps it up to date by watching vectors from the accelerometer…)

  2. Speed8ump says :

    Dead reckoning would require two three axis accelerometers, one for axial acceleration and one for rotational acceleration. Without this the device can’t distingush between changes in tilt and lateral movement.

  3. Zeeshan Khan says :

    sample code link is not working.
    Giving 404 Page Not Found error. If you have the code then please send it to me, I need an example of accelerometer.
    Thanks in advance
    Zeeshan Khan

%d bloggers like this: