from microbit import *
while True:
gesture = accelerometer.current_gesture()
if gesture == "face up":
display.show(Image.HAPPY)
else:
display.show(Image.ANGRY)
Gestures:
Úloha: Pomocou obrázkov Image.ARROW_N
, Image.ARROW_E
, Image.ARROW_S
a Image.ARROW_W
naprogramuj micro:bit tak, aby pri akomkoľvek naklonení smerovala šípka na obrazovke smerom hore.
from microbit import display, acceletometer, sleep
import random
while True:
if accelerometer.was_gesture("shake"):
display.clear()
sleep(1000)
display.scroll(random.randint(1, 15))
cez get_x()