views:

77

answers:

1

I'm using the accelerometer to move an object on my screen. It's only working when the iphone is flat.

If I use the iPhone in another position, the object is not moving like I want (the Y axis is not well managed).

So, I've to calibrate the position of the accelerometer, I guess. But I've no idea how to do this.

Please help me.

Thanks in advance.

Regards, ALpesH

A: 

hi hope all is well. A simple google search came up with this beautiful post. It is exactly what you wanted. A tutorial on Accelerometer Calibration & Optimizations.

This tutorial assumes you know the basics of the accelerometer. If not there are plenty of tutorials on google that will help get you accustomed to the accelerometer basics.

This tutorial will focus on 3 things:

  1. Calibrating the accelerometer so the user can play your game from any position.
  2. Changing the "sensitivity" of your object's movement.
  3. Adding the option to "invert" the controls.

First off, why bother adding these features? Simple. Launch your accelerometer based game and try the following tests:

  1. Play sitting up in perfect position.
  2. List item
  3. Play it slouched over.
  4. Play it lying down on your side.
  5. Play it lying on your back with the device parallel to the floor and the screen facing you.

Obtained from this website:

http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/39833-tutorial-accelerometer-calibration-optimizations.html

Let me know if this helps if it does choose this as the answer. Other than that if you need any more help let me know

Ive implemented this tutorial code in my own app and i am not playing a simple ping pong game upside down and also playing it on the side whilst lying on the bed. :D

Pk

Pavan