Skip to content

Instantly share code, notes, and snippets.

@andreagrandi
Created February 27, 2016 23:43
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/1e2f6e591f218ba612d9 to your computer and use it in GitHub Desktop.
Save andreagrandi/1e2f6e591f218ba612d9 to your computer and use it in GitHub Desktop.
DontShakeMe is an example written in Python that uses microbit accelerometer
# DontShakeMe - Andrea Grandi (2016)
# License: MIT
from microbit import display, Image, accelerometer, sleep
# display an happy face by default
display.show(Image.HAPPY)
# if you shake the device, you make microbit sad
while True:
if accelerometer.was_gesture('shake'):
display.show(Image.SAD)
sleep(2000)
display.show(Image.HAPPY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment