Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6934129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:55:14+00:00 2026-05-27T11:55:14+00:00

I am creating a motion detection alarm for the iPhone. This alarm will be

  • 0

I am creating a motion detection alarm for the iPhone. This alarm will be set by pressing an ‘Activate’ button, and after a small countdown, will then take readings about whether it is moving. I have tried using the accelerometer to detect movement, but if the threshold becomes too low it activates constantly, whether the device is moving or not. If I set the threshold higher it does not detect movement, and will only detect specific speeds of motion.

Does anyone have any solutions as to how to do this correctly, not by an amount of force, but whether the phone has actually moved.

I have tried to find online examples of how to implement it but only came up with solutions for augmented reality and OpenGL etc. All I need is a simple detection of motion.

Thank you for any help!

EDIT:

I managed to get it working using some samples from the Apple documentation.

I’ve managed to achieve what I want using this accelerometer didAccelerate method:

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
    // Use a basic low-pass filter to keep only the gravity component of each axis.
    accelX = (acceleration.x * kFilteringFactor) + (accelX * (1.0 - kFilteringFactor));
    accelY = (acceleration.y * kFilteringFactor) + (accelY * (1.0 - kFilteringFactor));
    accelZ = (acceleration.z * kFilteringFactor) + (accelZ * (1.0 - kFilteringFactor));

    float accelerationThreshold = 1.01; // or whatever is appropriate - play around with different values

    if (fabs(accelX) > accelerationThreshold || fabs(accelY) > accelerationThreshold || fabs(accelZ) > accelerationThreshold) {
        [self.soundPlayer play];
        accelX = accelY = accelZ = 0;
        accelerometerActive = NO;
        accelerometer.delegate = nil;
        accelerometer = nil;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:55:15+00:00Added an answer on May 27, 2026 at 11:55 am

    One way to do this could be to calculate a vector for gravity. If the phone isn’t moving then the vector will remain fairly constant. Should the phone be picked up it is likely that the orientation of the phone will change, thus the gravity vector will also change (in relation to the orientation of the accelerometer).

    To detect movement simply calculate the angle between the original vector set on ‘Activate’ and the current vector. Googling angles between 3d vectors will help you out with the mathmatics behind this.

    Theoretically someone could pick the phone up and maintain the exact orientation but this is incredibly unlikely.

    Hope this helps and good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(creating a separate question after comments on this: Javascript redeclared global variable overrides old
I'm creating an interactive e-book for the iPad. This book will contain multiple pages
I'm creating heightmaps using Fractal Brownian Motion. I'm then coloring it based on the
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
Creating a server-side socket will fail if I'm trying to use the same port
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
I'm new to wxPython, so bear with me. I'm creating a custom GUI set
Creating a calculator-like dialog, I noticed that quickly clicking on a button in IE
Creating a table without tbody using javascript createElement/appendChild will not add tbody in Firebug
Creating extensions got much easier with Vs2010, but this seems not to be the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.