timeout = 10 start_time = time.time() while time.time() - start_time < timeout: if not button_pin.value(): change_fire_color() while not button_pin.value(): time.sleep(0.01) fire_effect() simulate_sparks()