Ajout projet masque "covid" animé grâce au mricrobit

- visage vers le haut = sourire
- visage vers le bas = sourire inversé
This commit is contained in:
Jérémie DUCASTEL
2020-05-10 16:22:00 +02:00
parent c465d5c9f1
commit 3ea8ea49c5
2 changed files with 40 additions and 0 deletions

15
accelerometer.py Normal file
View File

@ -0,0 +1,15 @@
# test choix de picto en fonction de l'orientation
from microbit import *
# tests
# while True:
# x = accelerometer.get_x()
# y = accelerometer.get_y()
# z = accelerometer.get_z()
# txt = "x={} y={} z={}".format(x, y, z)
# display.scroll(txt)
# sleep(500)
# neutre : X = -32, y = 1024, z = -60
# haut : X = -28, y = 1000, z = -232
# bas : X = -28, y = 1000, z = 240# Ecrit ton programme ici ;-)

25
masque.py Normal file
View File

@ -0,0 +1,25 @@
# test choix de picto en fonction de l'orientation
from microbit import *
# creation des images
good_img = Image("50005:90009:09990:00000:00000")
bad_img = Image("00000:00000:09990:90009:50005")
neutral_img = Image("00000:00000:00000:00000:0000")
emotion = "neutral" # neutral / good / bad
# boucle infinie
while True:
# definition de l'humeur a partir de l'accelerometre
z = accelerometer.get_z()
if z < 0:
emotion = "good"
elif z > 400:
emotion = "bad"
# affichage de la derniere humeur enregistree
if emotion == "good":
display.show(good_img)
elif emotion == "bad":
display.show(bad_img)
sleep(200)