# simple neopixel ring demo 23 Nov 2021 - @todbot
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=1.0, 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 = 20  # 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 + 10) % 255  # change hue if button pressed
    print("hue:",my_hue)
  time.sleep(0.1)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT