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

from adafruit_circuitplayground import cp


noise_heard = False
Line_0 = False
Line_1 = False
Line_2 = False
Line_3 = False
turned_on = False


while True:
    print(cp.light)
    if cp.light <= 2 and turned_on == False:
        time.sleep(15)
#This is the wake up line. Change "Line_0.wav" into your complete file name (plus the quotation marks) to change it.
        cp.play_file("Line_0.wav")
        turned_on = True
    print(noise_heard)
    print(turned_on)
    if cp.loud_sound(sound_threshold = 50) and turned_on == True:
        noise_heard = True
        print(noise_heard)
    print(noise_heard)
    if noise_heard == True and Line_1 == False:
        time.sleep(5)
#This is the first line in response to hearing a noise. Again, change "Line_1.wav" into your complete file name, plus quotation marks.
        cp.play_file("Line_1.wav")
        noise_heard = False
        Line_1 = True
        print(noise_heard)
        print(Line_1)
    elif noise_heard == True and Line_2 == False:
        time.sleep(5)
#This is the second line in response to hearing a noise. Again, change "Line_2.wav" into your complete file name, plus quotation marks.
        cp.play_file("Line_2.wav")
        noise_heard = False
        Line_2 = True
        print(noise_heard)
        print(Line_2)
    elif noise_heard == True and Line_3 == False:
        time.sleep(5)
#This is the final line in response to hearing a noise. Again, change "Line_3.wav" into your complete file name, plus quotation marks.
        cp.play_file("Line_3.wav")
        noise_heard = False
        Line_3 = True
        print(noise_heard)
        print(Line_3)
    time.sleep(.01)



