15

Accessing the Sensors

WHAT YOU WILL LEARN IN THIS CHAPTER

  • How to obtain the gyroscope data from your iOS device
  • How to obtain accelerometer data from your iOS device
  • How to detect shakes to your device

Beginning with iPhone 4, Apple introduced a new gyroscopic sensor in addition to the original accelerometer sensor available since the first iPhone. Using the gyroscope, you can measure the device's angular acceleration around the x, y, and z axes. This enables you to accurately measure the yaw, pitch, and roll of the device. In addition to the gyroscope, the built-in accelerometer measures the linear acceleration of the device along the three axes. With these two sensors, your application can determine how far, how fast, and in which direction it is moving in space.

In this chapter, you learn how to access the gyroscope and accelerometer data and use the Shake API to detect shakes to your iPhone.

image

FIGURE 15-1

Get Beginning iOS 5 Application Development 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.