import time
from neopixel import Neopixel
from machine import Pin

pixels = Neopixel(17, 0, 6, "GRB")
sw = Pin(2, Pin.IN, Pin.PULL_DOWN)

colors = [
    (0xb6, 0xe4, 0x30),
]

pixel_index = 0
pixel_index2 = 0
color_index = 0
led_state = False
button_state = False
button_last_state = False
button_pressed = False

def run_animation():
    global pixel_index, color_index, pixel_index2
    pixels.set_pixel(pixel_index, colors[color_index])
    pixels.set_pixel(pixel_index2, colors[color_index])
    pixels.show()
    pixel_index -= 1
    pixel_index2 += 1
    if pixel_index == -9:
        pixel_index = 0
        color_index = (color_index) % 2
    if pixel_index2 == 9:
        pixel_index2 = 0
        color_index = (color_index) % 2

def buttn():
    global pixel_index, color_index, led_state, button_state, button_last_state, button_pressed
    button_state = sw.value()

    if button_state and not button_last_state:
        button_pressed = not button_pressed
        if button_pressed:
            led_state = not led_state
            if led_state:
                print("LEDs ON")
            else:
                print("LEDs OFF")
                pixel_index = 0
                pixel_index2 = 0
                

    button_last_state = button_state

    if button_pressed and led_state:
        run_animation()
    elif not led_state:
        pixels.fill((0, 0, 0))
        pixels.show()

while True:
    buttn()
    time.sleep(0.1)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT