# Rmemeber to run : mpremote connect port:rfc2217://localhost:4000 run main.py
from  machine import Pin
from buzer_music import music
import time
KEY = Pin(4, Pin.IN, Pin.PULL_UP)
LED = Pin(5, Pin.OUT)
State = False
song = '0 A#3 1 0;0 F#3 2 0;1 C#4 1 0;2 C4 1 0;3 C#4 1 0;4 A#3 1 0;6 A#3 1 0;6 F#3 2 0;7 C4 1 0'
mySong = music(song, pins=[Pin(18)])



while True:
    if KEY.value()==0:
       time.sleep(0.1)
       if KEY.value()==0:
           State =not State
           LED.value(State)
           mySong.restart()
           

    else :
        print ("Press and hold")
        LED.value(False)
        mySong.stop()
    time.sleep(0.1)