import neopixel
from machine import Pin, ADC
from utime import sleep
import random
potPin=25
gumb=Pin(21, Pin.IN,Pin.PULL_UP)
NUM_LED=16
NUM_CIR=3
pot=ADC(Pin(potPin))
leds = neopixel.NeoPixel(Pin(16), NUM_LED*NUM_CIR)
def convert(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min
while True:
r=255
g=0
b=0
for x in range(NUM_LED*NUM_CIR):
if gumb.value()==0:
r=random.randint(0,255)
g=random.randint(0,255)
b=random.randint(0,255)
print(gumb.value())
s=(convert(pot.read(),0,4096,0,100))*0.01
leds[x]=[r,g,b]
leds.write()
sleep(s)
if x==NUM_LED*NUM_CIR-1:
leds.fill([0,0,0])