Вот код:
Код:
cmd = 1 mus = [Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.G, Note.C, Note.D, Note.E, Note.F, Note.F, Note.F, Note.F, Note.F, Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.E, Note.G, Note.C, Note.D, Note.E, Note.F, Note.F, Note.F, Note.F, Note.F, Note.E, Note.E, Note.E, Note.G, Note.G, Note.F, Note.D, Note.C ] def on_button_pressed_a(): global cmd cmd = cmd + 1 def on_button_pressed_b(): global cmd global mus if cmd == 1: for m in mus: if cmd != 1: break music.play_tone(m, 100) basic.pause(500) if cmd == 2: while True: if cmd != 2: break basic.show_leds(""" # # . . . # # . . . . . . . . . . . . . . . . . . """) basic.pause(500) basic.show_leds(""" . . . . . . . . . . . . . . . . . . # # . . . # # """) if cmd == 3: while True: if cmd != 3: break basic.show_leds(""" # . . . . . . . . . . . . . . . . . . . . . . . . """) basic.pause(50) basic.show_leds(""" # . . . . # # . . . . . . . . . . . . . . . . . . """) basic.pause(50) basic.show_leds(""" # . . . . # # . . . # # # . . . . . . . . . . . . """) basic.pause(50) if cmd == 4: basic.clear_screen() cmd = 1 input.on_button_pressed(Button.A, on_button_pressed_a) input.on_button_pressed(Button.B, on_button_pressed_b)
Результат работы см. тут:
https://cloud.mail.ru/public/u4ix/x9qynJjfU