Skip to content

Instantly share code, notes, and snippets.

@andreagrandi
Created January 25, 2016 23:16
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 andreagrandi/f4a7c8ee8597dde3070d to your computer and use it in GitHub Desktop.
Save andreagrandi/f4a7c8ee8597dde3070d to your computer and use it in GitHub Desktop.
MicroBit accelerometer example: show an happy face if kept straight or a sad one if bended
import microbit as m
SENSITIVITY = 250
while (True):
x = m.accelerometer.get_x()
if abs(x) < SENSITIVITY:
m.display.show(m.Image.HAPPY)
else:
m.display.show(m.Image.SAD)
m.sleep(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment