Created
February 27, 2016 23:43
-
-
Save andreagrandi/1e2f6e591f218ba612d9 to your computer and use it in GitHub Desktop.
DontShakeMe is an example written in Python that uses microbit accelerometer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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