mirror of
https://forge.apps.education.fr/blender-edutech/blender-edutech-tutoriels.git
synced 2024-01-27 09:42:33 +01:00
Tutoriels 5 : programmes ok
This commit is contained in:
parent
a643bf86f4
commit
a8d8134d64
@ -120,7 +120,8 @@ void loop() {
|
|||||||
|
|
||||||
// Victoire
|
// Victoire
|
||||||
if (xy==92) matrix.writeOnePicture(0x003c428100666600);
|
if (xy==92) matrix.writeOnePicture(0x003c428100666600);
|
||||||
|
|
||||||
|
// Affichage
|
||||||
matrix.display();
|
matrix.display();
|
||||||
serial_msg = "";
|
serial_msg = "";
|
||||||
serial_msg_complet = false;
|
serial_msg_complet = false;
|
||||||
|
@ -18,7 +18,7 @@ from microbit import *
|
|||||||
# Initialisation
|
# Initialisation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
attente_image = Image("00000:00000:00900:00000:00000")
|
attente_image = Image("00000:00000:00300:00000:00000")
|
||||||
display.show(attente_image) # Témoin de fonctionnement
|
display.show(attente_image) # Témoin de fonctionnement
|
||||||
|
|
||||||
uart.init(baudrate= 115200) # Initialisation du port série
|
uart.init(baudrate= 115200) # Initialisation du port série
|
||||||
@ -31,29 +31,28 @@ msg_str=''
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
# A propos
|
||||||
|
if button_a.is_pressed() or button_b.is_pressed():
|
||||||
|
display.scroll("Labyrinte")
|
||||||
|
display.show(attente_image) # Témoin de fonctionnement
|
||||||
|
|
||||||
# Inclinaison de la carte -> UBGE
|
# Inclinaison de la carte -> UBGE
|
||||||
accel_x=accelerometer.get_x() # Roulis
|
accel_x=accelerometer.get_x() # Roulis
|
||||||
accel_y=accelerometer.get_y() # Tangage
|
accel_y=accelerometer.get_y() # Tangage
|
||||||
uart.write(str(accel_x)+","+str(accel_y)+"\n")
|
uart.write(str(accel_x)+","+str(accel_y)+"\n")
|
||||||
|
|
||||||
# UBGE -> micro:bit (lecture du message)
|
# UBGE -> micro:bit (lecture du message)
|
||||||
new_byte = (uart.read(1))
|
msg_byte = uart.readline()
|
||||||
if new_byte == None:
|
if msg_byte:
|
||||||
continue
|
|
||||||
new_char = str(new_byte, 'ascii')
|
|
||||||
msg_str += new_char
|
|
||||||
|
|
||||||
# Affichage de la position de la bille
|
|
||||||
if ("\n" in msg_str):
|
|
||||||
display.clear()
|
display.clear()
|
||||||
|
msg_str = str(msg_byte, 'ascii')
|
||||||
if "91" in msg_str: # Chute
|
if "91" in msg_str: # Chute
|
||||||
display.show(Image.ANGRY)
|
display.show(Image.SAD)
|
||||||
uart.write("start\n")
|
sleep(500);
|
||||||
|
uart.write("start\n")
|
||||||
elif "92" in msg_str: # Victoire
|
elif "92" in msg_str: # Victoire
|
||||||
display.show(Image.HAPPY)
|
display.show(Image.HAPPY)
|
||||||
uart.write("start\n")
|
|
||||||
else: # Position de la bille
|
else: # Position de la bille
|
||||||
display.set_pixel(int(msg_str[0]), int(msg_str[1]), 9)
|
display.set_pixel(int(msg_str[0]), int(msg_str[1]), 9)
|
||||||
msg_str = ''
|
|
||||||
|
|
||||||
sleep(100)
|
sleep(100)
|
||||||
|
Loading…
Reference in New Issue
Block a user