Chapter 31. Working with the Accelerometer
In This Chapter
Using the accelerometer to determine the orientation of the device |
Using a low-pass filter to smooth the input from the accelerometer |
Implementing shake motion detection in a custom UIView |
In November 2006, Nintendo introduced the Nintendo Wii. The Nintendo Wii contained a variety of innovative controller mechanisms, but one in particular was especially revolutionary. The controllers that shipped with the Nintendo Wii contained accelerometers, small electronic components inside the controllers that could detect the orientation and motion of the controllers themselves. Using the accelerometers, the Nintendo Wii launched a completely new gaming experience, by unlocking the ability for the players to use their whole bodies as game controllers.
Nearly a year later, when Apple introduced the first iPhone, it also contained an accelerometer, and the accelerometer built into the iPhone was probably as revolutionary for mobile application development as it was for the Nintendo Wii.
Make no mistake; accelerometers are nothing new in the world of electronics. But making accelerometers available to application developers as part of the standard hardware on the device opens up a completely new user experience. It opens up new ways of interacting with applications that were not available before.
In this chapter, you'll learn how to harness the accelerometer so that you can use it in your application.
Determining Which Way Is Up
The accelerometer ...
Get Cocoa Touch™ for iPhone® OS 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.