system.setAccelerometerInterval()

Type Function
Library system.*
Return value none
Revision Release 2024.3703
Keywords accelerometer
See also accelerometer

Overview

Sets the frequency of accelerometer events.

On both Android and iOS, the default value is not documented but it is typically low, for example 10 Hz.

Accelerometer events are a significant drain on the battery, so only increase the frequency when you need faster responses.

Gotchas

settings =
{
    iphone =
    {
        plist =
        {
            NSMotionUsageDescription = "This app would like to access the accelerometer.",
        },
    },
}

Syntax

system.setAccelerometerInterval( frequency )
frequency (required)

Number. The measurement interval in Hz.

Example

-- Set the measurement interval to 50 Hz
-- This makes the system take 50 measurements per second
system.setAccelerometerInterval( 50 )