import board, neopixel, time, random, digitalio, touchio, adafruit_lis3dh, busio, pwmio, analogio


#If you connected your white alligator clip to something other than A1, change A1 to whatever you chose in the line below!
strip_pin = board.A1
strip_num_of_lights = 30
strip = neopixel.NeoPixel(strip_pin, strip_num_of_lights, brightness = 1, auto_write = True)

BLACK = (0,0,0)


#Modify these Variables in order to change which lights on your strip light up. The lights begin counting up from zero!
#Try changing these and seeing which lights turn on, and adjusting until you get the ones behind the eyes and mouth.
x1 = 19
x2 = 20
x3 = 21
x4 = 6
x5 = 7

def flaming_strip():
#Modify these variables to match your changes above!
    x1 = 19
    x2 = 20
    x3 = 21
    x4 = 6
    x5 = 7
    x = random.randint(200,255)
    y = random.randint(10,40)
    z = random.randint(0, 2)
    flame_1 = (x,y,z)
    a = random.randint(200,255)
    b = random.randint(10,40)
    c = random.randint(0, 2)
    flame_2 = (a,b,c)
    X = random.randint(200,255)
    Y = random.randint(10,40)
    Z = random.randint(0, 2)
    flame_3 = (X,Y,Z)
    A = random.randint(200,255)
    B = random.randint(10,40)
    C = random.randint(0, 2)
    flame_4 = (A,B,C)
    flames = [flame_1, flame_2, flame_3, flame_4]
    strip.brightness = random.randint(45, 99) / 100
    strip[x1] = random.choice(flames)
    strip[x2] = random.choice(flames)
    strip[x3] = random.choice(flames)
    strip[x4] = random.choice(flames)
    strip[x5] = random.choice(flames)
    time.sleep(.1)


light_sensor = analogio.AnalogIn(board.LIGHT)
turned_on = False

def waking_up():
    global turned_on
    if light_sensor.value < 300:
        turned_on = True
    time.sleep(2.5)
    if turned_on == True:
        strip.brightness = 0
        for i in range(50):
            strip[x1] = (255,10,0)
            strip[x2] = (255,10,0)
            strip[x3] = (255,10,0)
            strip[x4] = (255,10,0)
            strip[x5] = (255,10,0)
            strip.brightness = i/100
            time.sleep(.02)
        pixels.fill(BLACK)
        time.sleep(1)
        for i in range(100):
            strip[x1] = (255,10,0)
            strip[x2] = (255,10,0)
            strip[x3] = (255,10,0)
            strip[x4] = (255,10,0)
            strip[x5] = (255,10,0)
            strip.brightness = i/100
            time.sleep(0.02)
        strip.fill(BLACK)
        time.sleep(.5)
        strip[x1] = (255,10,0)
        strip[x2] = (255,10,0)
        strip[x3] = (255,10,0)
        strip[x4] = (255,10,0)
        strip[x5] = (255,10,0)
        time.sleep(1)
        strip.fill(BLACK)
        time.sleep(.5)
        strip[x1] = (255,0,0)
        strip[x2] = (255,0,0)
        strip[x3] = (255,0,0)
        strip[x4] = (255,0,0)
        strip[x5] = (255,0,0)
    time.sleep(0.1)



talking = True

while True:
    strip.fill(BLACK)
    print(turned_on)
    waking_up()
    print (light_sensor.value)
    print(turned_on)
    while turned_on == True:
        flaming_strip()
