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

delay = 0.0
NUM_LEDS = 100
leds = neopixel.NeoPixel(Pin(4), NUM_LEDS)
barve = []
R = random.randint(0, 255)
G = random.randint(0, 255)
B = random.randint(0, 255)

while True:
  R = random.randint(0, 255)
  G = random.randint(0, 255)
  B = random.randint(0, 255)
  Colour = [R, G, B]
  for i in range(NUM_LEDS):
    leds[i] = Colour
    leds.write()
    sleep(delay)
    if len(barve) == NUM_LEDS:
      barve.clear()
    if i == (NUM_LEDS-1)-len(barve):
      barve.insert(i, Colour)
      break
    else:
      leds[i] = [0, 0, 0]
    leds.write()

"""
while True:
  R = random.randint(0, 255)
  G = random.randint(0, 255)
  B = random.randint(0, 255)
  Colour = [R, G, B]
  for i in range(NUM_LEDS):
    leds[i] = Colour
    leds.write()
    sleep(delay)
    if i == 23-len(barve):
      barve.insert(i, Colour)
    else:
      leds[i] = [0, 0, 0]
    leds.write()"""