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

NUM_LEDS = 16
cas=5

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

while True:
    r=random.randrange(0,NUM_LEDS)
    for x in range(NUM_LEDS):
        if time.time() >= cas:
            if x==r:
                leds[x]=[255,255,255]
                leds.write()
                sleep(2)
                leds[x]=[0,0,0]
                leds.write()
                cas=time.time()+5

            else:
                leds[x]=[255,255,255]
                leds.write()
                sleep(0.05)
                leds[x]=[0,0,0]
                leds.write()
        else:
            leds[x]=[255,255,255]
            leds.write()
            sleep(0.05)
            leds[x]=[0,0,0]
            leds.write()