# Accelerometer

Code to interface Accelerometer(MMA8X5X) using python

```
#!/usr/bin/env python

from __future__ import print_function
import time, sys,atexit
from upm import pyupm_mma8x5x as MMA8X5X

def main():
    # Instantiate the Three-Axis Accelerometer Sensor on I2C on bus 1
    mySensor = MMA8X5X.MMA8X5X(2)
    data = MMA8X5X.mma8x5x_data_t()
    # activate periodic measurements
    mySensor.setActive();

    # Print out the x, y, z value every 0.5 seconds
    while(1):
        mySensor.getData(data, True)
        print(&quot;X-Axis : &quot;+str(data.x),&quot;Y-Axis : &quot;+str(data.y),&quot;Z-Axis : &quot;+str(data.z))
        time.sleep(.5)
if __name__ == &#39;__main__&#39;:
    main()
```

**To run the program,** \
**Step 1: save the file as mma8x5x.py**\
**Step 2: Run the Program in the board's terminal using** `python3 mma8x5x.py`
