from machine import Pin,ADC
from time import sleep
import neopixel
import random
num_leds=16
tipkaZ=Pin(19,Pin.IN,Pin.PULL_UP)
tipkaR=Pin(15,Pin.IN,Pin.PULL_UP)
pot= ADC(Pin(26))
ring=neopixel.NeoPixel(Pin(12),num_leds)
a= 0
while True:
#1.naloga
while a<4:
ring.fill([255, 0, 0])
ring.write()
sleep(max(pot.read()/10000,0.1))
ring.fill([0, 0, 255])
ring.write()
sleep(max(pot.read()/10000,0.1))
a+=1
#2.naloga
while a<5:
for i in range(num_leds):
ring[i] = [0, 255,0]
ring.write()
sleep(max(pot.read()/10000,0.1))
a+=1
#3.naloga
while a<8:
red = random.randrange(100, 255)
green = random.randrange(100, 255)
blue = random.randrange(100, 255)
for i in range(num_leds):
ring[i] = (red, green, blue)
ring.write()
sleep(max(pot.read()/10000,0.1))
a+=1
#4.naloga
while a<10:
for i in range(num_leds):
if tipkaZ.value()==0:
ring[-i]=[0, 255, 0]
ring.write()
sleep(max(pot.read()/10000,0.1))
elif tipkaZ.value()==1:
ring[i]=[255, 0 ,0]
ring.write()
sleep(max(pot.read()/10000,0.1))
a+=1