from machine import Pin,ADC
from utime import sleep 
import neopixel 
import random
import time

NUM_LEDS = 16

leds = neopixel. NeoPixel (Pin(15), NUM_LEDS)

button=Pin(4,Pin.IN,Pin.PULL_UP)

while True:
    leds.fill([7,255,7])
    leds.write()
    while True:
        for x in range(random.randrange(1,5)*100):
            sleep(0.01)
            if button.value()==0:
                print("To early")
        break

    leds.fill([255,7,7])
    leds.write()
    start=time.time_ns()
    while True:
        if button.value()==0:
            finish=time.time_ns()
            leds.fill([7,255,7])
            leds.write()
            break
    time1=finish-start
    print(time1/1000000000)
    sleep(2)