I'm trying to use a BBC:Microbit to display a flash for 1 second on it's led's when button a is pressed. This works but I want it to display an animation(standby) whilst it waits for the button to be pressed. The code below only shows the standby image and does not run the rest of the code when button a is pressed. What have I got wrong? Thanks.
from microbit import *
standby1 = Image("00000:"
"00000:"
"90000:"
"00000:"
"00000")
standby2 = Image("00000:"
"00000:"
"09000:"
"00000:"
"00000")
standby3 = Image("00000:"
"00000:"
"00900:"
"00000:"
"00000")
standby4 = Image("00000:"
"00000:"
"00090:"
"00000:"
"00000")
standby5 = Image("00000:"
"00000:"
"00009:"
"00000:"
"00000")
all_leds_on = Image("99999:"
"99999:"
"99999:"
"99999:"
"99999")
standby = [standby1, standby2, standby3, standby4, standby5, standby4, standby3, standby2]
display.show(standby, loop=True, delay=100)#Show standby LEDS on a loop
#Wait for button a to be pressed
while True:
if button_a.was_pressed():
sleep(1000)#pause program for 1 second
display.show(all_leds_on) #Turn on LEDS for 1 second
sleep(1000)#pause program for 1 second
display.clear()