def ghost(): global offset if pix_col == 255: light.set_pixel_color(pic_col, 0x0000ff) light.set_pixel_color(rng - 1, 0x000000) offset = 1 else: if offset == 0: light.set_pixel_color(rng - 1, 0x000000) offset = 0 offset = 0 pause(100) def on_button_a_click(): global rng, pix_col, pic_col, value rng += 1 pix_col = light.pixel_color(rng) pic_col = rng if rng > 9: light.set_pixel_color(rng - 1, 0x000000) rng = 0 pix_col = light.pixel_color(rng) pic_col = rng ghost() light.set_pixel_color(rng, 0xff0000) ghost() value = 1 / (1 / rng) * 10 + dly * 1 input.button_a.on_event(ButtonEvent.CLICK, on_button_a_click) def on_button_b_click(): global mode light.clear() pause(100) mode += 1 if mode > 1: mode = 0 light.set_pixel_color(rng, 0xff0000) light.set_pixel_color(dly, 0x000000) pause(100) input.button_b.on_event(ButtonEvent.CLICK, on_button_b_click) mode = 0 value = 0 offset = 0 pic_col = 0 pix_col = 0 rng = 0 dly = 0 dly = 0 rng = 0 light.set_brightness(255) light.set_pixel_color(0, 0xff0000) pins.A1.digital_write(False) list2 = [Colors.RED, Colors.ORANGE, Colors.YELLOW, Colors.GREEN, Colors.BLUE, Colors.INDIGO, Colors.VIOLET, Colors.PURPLE, Colors.WHITE] def on_forever(): if mode == 1 and value > 0: light.set_all(0xffffff) pause(value) light.set_all(0x000000) else: pins.A1.digital_write(True) pause(value) pins.A1.digital_write(False) forever(on_forever)