import time
import neopixel
import _thread
import random


def run():
    color = 0
    inc = True
    leds = [0x00, 0x00, 0x00] * 12
    while True:
        for i in range(len(leds)):
            if random.uniform(0, 1) > 0.3:
                if i % 3 == color:
                    if leds[i] >= 0x64: # 100
                        inc = False
                    elif leds[i] <= 0x00:
                        inc = True

                    if inc:
                        leds[i] += 1
                    else:
                        leds[i] -= 1

        if random.uniform(0, 1) > 0.6:
            color += 1
            if color > 2:
                color = 0

        neopixel.send(bytes(leds))
        time.sleep_ms(1)

def init():
    _thread.start_new_thread("LED", run, ())