# Get accelerometer free from the frame-rate

**URL:** https://discourse.processing.org/t/get-accelerometer-free-from-the-frame-rate/3866
**Category:** Processing for Android
**Created:** [September 26, 2018, 3:43pm UTC](https://discourse.processing.org/t/get-accelerometer-free-from-the-frame-rate/3866 "2018-09-26T15:43:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chanof](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@chanof](https://discourse.processing.org/u/chanof)
#### Post date: [September 26, 2018, 3:43pm UTC](https://discourse.processing.org/t/get-accelerometer-free-from-the-frame-rate/3866/1 "2018-09-26T15:43:51Z")

</div>

Hi there! May i ask a help to understand how to get accelerometer free from frame-rate?  
Currently i using it as the tutorial below teach,  
I need sensor to drive sound fx, my currently framerate is only 16 fps and i can’t increase it,  
How can i modify it to use it as a thread independent from draw void frame-rate?  
Thanks!

[https://android.processing.org/tutorials/sensors/index.html](https://android.processing.org/tutorials/sensors/index.html)

This is my current situation about, that i learn form the link above

```auto
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;

Context context;
SensorManager manager;
Sensor sensor;
AccelerometerListener listener;
float ax, ay, az;

void setup() {
  fullScreen();
  
  context = getActivity();
  manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
  sensor = manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
  listener = new AccelerometerListener();
  manager.registerListener(listener, sensor, SensorManager.SENSOR_DELAY_GAME);
  
  textFont(createFont("SansSerif", 30 * displayDensity));
}

void draw() {
  background(0);
  text("X: " + ax + "\nY: " + ay + "\nZ: " + az, 0, 0, width, height);
}

class AccelerometerListener implements SensorEventListener {
  public void onSensorChanged(SensorEvent event) {
    ax = event.values[0];
    ay = event.values[1];
    az = event.values[2];    
  }
  public void onAccuracyChanged(Sensor sensor, int accuracy) {
  }
}

```

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [September 26, 2018, 3:54pm UTC](https://discourse.processing.org/t/get-accelerometer-free-from-the-frame-rate/3866/2 "2018-09-26T15:54:58Z")

</div>

Hi chanof,

Did you have a look at the [thread()](https://processing.org/reference/thread_.html) function?

---

<div class="post-metadata">

### Author: ![chanof](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@chanof](https://discourse.processing.org/u/chanof)
#### Post date: [September 26, 2018, 10:59pm UTC](https://discourse.processing.org/t/get-accelerometer-free-from-the-frame-rate/3866/3 "2018-09-26T22:59:13Z")

</div>

Hi @jb4x yes i know and i want use it but i dont know how to apply it here  
May i ask if you can show how?  
Thanks
