Skip to content

Instantly share code, notes, and snippets.

@li2hub
Last active April 2, 2019 11:06
Show Gist options
  • Save li2hub/5c509026fc88aa97ac84c28b606b5a68 to your computer and use it in GitHub Desktop.
Save li2hub/5c509026fc88aa97ac84c28b606b5a68 to your computer and use it in GitHub Desktop.
import time
import Adafruit_ADXL345
accel = Adafruit_ADXL345.ADXL345()
print('Printing X, Y, Z axis values, press Ctrl-C to quit...')
while True:
# Read the X, Y, Z axis acceleration values and print them.
x, y, z = accel.read()
print('X={0}, Y={1}, Z={2}'.format(x, y, z))
# Wait half a second and repeat.
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment