# Imports
from machine import Pin
from neopixel import NeoPixel
import time, random

# LED details
GPIOnumber = 28
LEDcount = 15

# Define the strand pin number and number of LEDs from variables
strand = NeoPixel(Pin(GPIOnumber), LEDcount)

# Turn off all LEDs before program start
strand.fill((0,0,0))
strand.write()
time.sleep(1)
        
while True:
    mycolour = random.randint(0,256),random.randint(0,256),random.randint(0,256)

    for i in range(LEDcount):
        
        strand[i] = (mycolour)
        strand.write()
        
        # Show the light for this long
        time.sleep(.09)
        
        #Clear the strand at the end of each loop
        strand.fill((0,0,0))
        strand.write()

    for i in reversed (range(LEDcount)):
        strand[i] =(mycolour)
        strand.write()
        
        # Show the light for this long
        time.sleep(.09)
        
        #Clear the strand at the end of each loop
        strand.fill((0,0,0))
        strand.write()
