import time
import machine
import neopixel
from machine import Pin, ADC
import random
button = Pin(2, Pin.IN, Pin.PULL_UP)
led_strip = neopixel.NeoPixel(Pin(15, Pin.OUT), 16)
led = Pin(13, Pin.OUT)
def reaction_time():
led.off()
time.sleep(random.uniform(2, 5))
led.on()
start_time = time.ticks_ms()
while button.value():
pass
end_time = time.ticks_ms()
led.off()
return end_time - start_time
while True:
print("Pritisni gumb, ko zagori LED!")
while button.value():
pass
time.sleep(1)
result = reaction_time()
print("Tvoj reakcijski čas je:", result, "ms")
print("")