# Iphone accelerometer sensitivity

I am moving an object with the accelerometer with the code from the scripting reference, which is this:

``````var speed = 25.0;

function Update ()
{

var dir : Vector3 = Vector3.zero;

//assuming device is parallel to ground and home button is in right hand

//xy plane of device is mapped onto XZ plane
//rotated 90 degrees around Y axis
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;

//clamp acceleration vector to unit sphere
if(dir.sqrMagnitude > 1)
{
dir.Normalize();
}

dir *= Time.deltaTime;

transform.Translate(dir * speed);
}
``````

I would like to know if there is a way to adjust the sensitivity of the accelerometer, so the iPhone would not have to be tilted as much in order to move the object.

You can multiply the dir vector by a sensitivity factor before checking itâ€™s magnitude:

```    dir = dir * 2.5; // adjust the sensitivity (2.5, in this case)
//clamp acceleration vector to unit sphere
if(dir.sqrMagnitude > 1)
{
dir.Normalize();
}
```

The accelerometer output may be a little shaky, so you may want to smooth it. If you want to do that, declare a Vector3 variable filter right after speed:

``````var speed = 25.0;
var filter = Vector3.zero;
``````

Then filter the dir vector before multiplying by Time.deltaTime:

```    if(dir.sqrMagnitude > 1)
{
dir.Normalize();
}
// adjust the lerp speed factor (3, in this case) if necessary
filter = Vector3.Lerp(filter, dir, 3*Time.deltaTime);
dir = filter * Time.deltaTime; // replace dir by the filtered value
transform.Translate(dir * speed);
}
```