0

I am wanting to have my device sense small vibrations, such as a small shake, or someone breathing. I am assuming that this is possible because the app store has a number of "Sleep Pattern Monitor" apps, and they have good reviews.

Does anyone know a way, using the accelerometer or gyroscope (or something else?) to sense these small movements or vibrations? If so, is there sample code?

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
  • These below links may be helpful for you friend. http://stackoverflow.com/questions/4807551/objective-c-detecting-a-shake http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone – Jayaraj Aug 25 '12 at 03:20

1 Answers1

1

You can look at

http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html

Which has some examples on what to do.

While building my app I needed device orientation so I subscribed to beginGeneratingDeviceOrientationNotifications which was a pain because it would actually trigger an event on every slight movement that occurred while the iPad was on my desk. From me just slightly moving the iPad to me typing on my keyboard while it was on my desk. I would look into both of those.

Bot
  • 11,868
  • 11
  • 75
  • 131
  • So there are quite a few examples on that page. Any in particular snippet that you used? – Nic Hubbard Aug 24 '12 at 19:04
  • You will need to play around with them to find which one best fits your needs. – Bot Aug 24 '12 at 19:12
  • But which method did you use to sense the typing of your keyboard? – Nic Hubbard Aug 24 '12 at 20:42
  • `beginGeneratingDeviceOrientationNotifications` then looked for `- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation `, even though it isn't rotating it comes in as a rotation event. – Bot Aug 24 '12 at 20:50