Chapter 13. Accessing the Accelerometer
WHAT YOU WILL LEARN IN THIS CHAPTER:
How to obtain accelerometer data from your iPad
How to detect shakes to your device
iPad's built-in accelerometer allows your program to detect the orientation of the device and adapt the content to suit the new orientation. For example, when you rotate your device sideways, the Safari Web browser automatically switches the screen to landscape mode so that you now have a wider viewing space.
In this chapter, you learn how to access the accelerometer and how to use the Shake API to detect shakes to your iPad.
USING THE ACCELEROMETER
The accelerometer in iPad measures the acceleration of the device relative to freefall. A value of 1 indicates that the device is experiencing 1 g of force exerting on it (1 g of force being the gravitational pull of the earth, which your device experiences when it is stationary). The accelerometer measures the acceleration of the device in three different axes: X, Y, and Z. Figure 13-1 shows the different axes measured by the accelerometer.
Table 13-1 shows the readings of the three axes when the device is in the various positions. Bear in mind that you will never see the exact same values as these, because they are always fluctuating due to the sensitivity of the accelerometer.
Figure 13.1. FIGURE 13-1
Table 13.1. The Various Readings of the X, Y, and Z Axes
Vertical upright ...