The accelerometer measures any force that causes acceleration in the x-, y-, or z-direction. Because the Finch is usually moving pretty slowly, the accelerometer mostly measures the acceleration due to gravity. When the Finch is sitting on a level surface, the acceleration due to gravity points through the base of the Finch, along the positive z-axis. If you instead position the Finch so that its beak is pointing at the ground, the acceleration due to gravity points along the positive x -axis. The accelerometer enables you to measure these differences.
The acceleration() method returns a tuple objects with five values. The first three are float values that measure the acceleration in the x-, y-, and z-directions; these values are between -1.5 and 1.5 (units are g’s of acceleration). The last two items in the tuple are Boolean values that indicate whether the robot is being tapped or shaken. The code below stores all five values in variables with informative names. The two Boolean values will not be used in this lesson because sometimes unintentional movements result in unexpected True values.