from machine import Pin
from neopixel import NeoPixel
import time
button = Pin(13, Pin.IN, Pin.PULL_UP)
pixel_pin = 22
pixel_count = 16
pin = Pin(pixel_pin, Pin.OUT)
np = NeoPixel(pin, pixel_count)
def on():
for i in range(pixel_count):
np[i] = (255, 20 + i * 10, 147 + i * 5)
np[15 - i] = (255, 245 - i * 10, 245 - i * 5)
np.write()
time.sleep(0.2)
def off():
np.fill((0, 0, 0))
np.write()
while True:
if not button.value():
on()
else:
off()
time.sleep(0.2)