''' Mission 10 - Reaction Tester Mild solution - 1B Add a function for an intro, and call the wait() function. This solution also includes the functin for countdown. ''' from codex import * import random import time def wait_button(): while True: if buttons.was_pressed(BTN_A): break # -- add intro function def intro(): display.print("Reaction Tester") display.print("When the pixels") display.print("turn GREEN") display.print("press BTN A") display.print() display.print("Press A to start") wait_button() display.clear() def countdown(): # clear screen and countdown display.clear() pixels.set([BLACK, BLACK, BLACK, BLACK]) display.print("3", scale=6) time.sleep(1) display.print("2", scale=6) time.sleep(1) display.print("1", scale=6) time.sleep(1) display.clear() # -- call intro intro() while True: display.print("Press Button A") wait_button() countdown() # get random delay time ms = random.randrange(1000, 5000) delay_time = ms / 1000 time.sleep(delay_time) # turn pixels GREEN buttons.was_pressed(BTN_A) pixels.set([GREEN, GREEN, GREEN, GREEN]) # get start and end time start_time = time.ticks_ms() wait_button() end_time = time.ticks_ms() reaction_time = time.ticks_diff(end_time, start_time) display.print("Reaction Time:") display.print(reaction_time) display.print("milliseconds")