Skip to content

Instantly share code, notes, and snippets.

@martinohanlon
Created April 18, 2019 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinohanlon/c2379def209411229bc95f45973fe2d3 to your computer and use it in GitHub Desktop.
Save martinohanlon/c2379def209411229bc95f45973fe2d3 to your computer and use it in GitHub Desktop.
from sense_hat import SenseHat
def display_acceleration(x, y, z):
print("{:06.2f}|{:06.2f}|{:06.2f}".format(x, y, z))
sense = SenseHat()
while True:
acceleration = sense.get_accelerometer_raw()
x = acceleration['x']
y = acceleration['y']
z = acceleration['z']
# display_acceleration(x,y,z)
x = abs(x)
y = abs(y)
z = abs(z)
if x > 1.6 or y > 1.6 or z > 1.6:
print("shaken")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment