Skip to content

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.

2 Comments

  1. Gordon wrote:

    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…)

    Tuesday, September 4, 2007 at 11:04 pm | Permalink
  2. Speed8ump wrote:

    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.

    Friday, September 21, 2007 at 3:07 pm | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 3 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a