import time, random
import board
from digitalio import DigitalInOut, Pull
from rainbowio import colorwheel
import neopixel
print("Hello, Pi Pico!")
num_leds = 16
leds = neopixel.NeoPixel(board.GP28, num_leds, brightness=10, auto_write=False )
button = DigitalInOut(board.GP0)
# defaults to input
button.pull = Pull.UP
# turn on internal pull-up resistor
my_hue = 0
dim_by = 10 # The tail dim led count
# dim amount, higher = shorter tails
pos = 0
# where on ring we are
while True:
leds[pos] = colorwheel( my_hue )
leds[0:] = [[max(i-dim_by,0) for i in l] for l in leds]
# dim LED by (dim_by)*3
pos = (pos+1) % num_leds
# move to next position
leds.show()
# only write to LEDs after updating them all
if button.value == False:
my_hue = (my_hue + 22) % 255 # changing hue value will upate the colour changing time
# change hue if button pressed
print("hue:",my_hue)
time.sleep(0.1) #speed of the LED rotaton