import neopixel
import random
from machine import Pin, ADC
from utime import sleep
import time, utime
NUM_LED = 30
gumb = Pin(27, Pin.IN, Pin.PULL_UP)
gumb2 = Pin(26, Pin.IN, Pin.PULL_UP)
pixels1 = neopixel.NeoPixel(Pin(5), NUM_LED)
potPin4 = 4
pot1 = ADC(Pin(4, Pin.IN))
while True:
if gumb2.value() == 0:
start = time.time()
for i in range(5):
st=0
a = random.randint(1, NUM_LEDS)
pixels1.fill([0,0,0])
pixels1[a] = [0,250,0]
pixels1.write()
poten = convert(pot1.read(),0,4096,0,NUM_LEDS)
time1 = 0
time2 = 0
while (time2-time1) <= 0.5:
time1 = time.time()
st += 1
a = random.randint(1, 30)
while poten != a:
pixels1[poten] = [250,0,0]
pixels1.write()
print(poten)
poten = convert(pot1.read(),0,4096,0,NUM_LEDS)
pixels1.fill([0,0,0])
pixels1[a] = [0,250,0]
pixels1.write()
time2 = time.time()
finish = time.time()
print("Čas: ", end ="")
print(finish-start,end="")
print("s")
print("Število ponovitev", end="")
print(st)