diff --git a/labyrinthe/4-arduino_pyserial/4-labyrinthe-imu/4-labyrinthe-imu.ino b/labyrinthe/4-arduino_pyserial/4-labyrinthe-imu/4-labyrinthe-imu.ino index 98e8cd3..8d6cad1 100644 --- a/labyrinthe/4-arduino_pyserial/4-labyrinthe-imu/4-labyrinthe-imu.ino +++ b/labyrinthe/4-arduino_pyserial/4-labyrinthe-imu/4-labyrinthe-imu.ino @@ -120,7 +120,8 @@ void loop() { // Victoire if (xy==92) matrix.writeOnePicture(0x003c428100666600); - + + // Affichage matrix.display(); serial_msg = ""; serial_msg_complet = false; diff --git a/labyrinthe/5-microbit/5-labyrinthe-microbit.py b/labyrinthe/5-microbit/5-labyrinthe-microbit.py index 16ecd4f..3eb9340 100644 --- a/labyrinthe/5-microbit/5-labyrinthe-microbit.py +++ b/labyrinthe/5-microbit/5-labyrinthe-microbit.py @@ -18,7 +18,7 @@ from microbit import * # 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 uart.init(baudrate= 115200) # Initialisation du port série @@ -31,29 +31,28 @@ msg_str='' 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 accel_x=accelerometer.get_x() # Roulis accel_y=accelerometer.get_y() # Tangage uart.write(str(accel_x)+","+str(accel_y)+"\n") # UBGE -> micro:bit (lecture du message) - new_byte = (uart.read(1)) - if new_byte == None: - continue - new_char = str(new_byte, 'ascii') - msg_str += new_char - - # Affichage de la position de la bille - if ("\n" in msg_str): + msg_byte = uart.readline() + if msg_byte: display.clear() + msg_str = str(msg_byte, 'ascii') if "91" in msg_str: # Chute - display.show(Image.ANGRY) - uart.write("start\n") + display.show(Image.SAD) + sleep(500); + uart.write("start\n") elif "92" in msg_str: # Victoire display.show(Image.HAPPY) - uart.write("start\n") else: # Position de la bille display.set_pixel(int(msg_str[0]), int(msg_str[1]), 9) - msg_str = '' sleep(100)