from machine import Pin, PWM
from utime import sleep, sleep_ms
back=Pin(17, Pin.IN)
start=Pin(18, Pin.IN)
nextt=Pin(4, Pin.IN)
sound1()
sound2()
sound3()
sound4()
sound5()
sound6()
sound7()
sound8()
sound9()
sound10()
sound11()
sound12()
sound13()
sound14()
sound15()
sound16()
def tone(buzzer_pin, freq, time):
    buzzer = PWM(Pin(buzzer_pin), freq=freq, duty=512)
    sleep_ms(time)
    buzzer.deinit()
def sound1():
    while True:
        tone(12, 440, 200)
        tone(12, 800, 100)
        tone(12, 350, 300)
        tone(12, 230, 600)
        tone(12, 900, 500)
        tone(12, 100, 670)
        tone(12, 820, 600)
        tone(12, 900, 490)
def sound2():
    while True:
        tone(12, 261, 300)
        tone(12, 261, 300)
        tone(12, 392, 300)
        tone(12, 392, 300)
        tone(12, 440, 300)
        tone(12, 440, 300)
        tone(12, 392, 600)
        tone(12, 349, 300)
        tone(12, 349, 300)
        tone(12, 329, 300)
        tone(12, 329, 300)
        tone(12, 293, 300)
        tone(12, 293, 300)
        tone(12, 261, 600)
def sound3():
    while True:
        tone(12, 140, 150)
        tone(12, 200, 150)
        tone(12, 92, 150)
        tone(12, 92, 150)
        tone(12, 840, 150)
        tone(12, 140, 150)
        tone(12, 92, 300)
        tone(12, 39, 150)
        tone(12, 39, 150)
        tone(12, 629, 150)
        tone(12, 629, 150)
        tone(12, 693, 150)
        tone(12, 193, 300)
        tone(12, 61, 600)
def sound4():
    while True:
        tone(12, 123, 100)
        tone(12, 123, 100)
        tone(12, 789, 200)
        tone(12, 789, 470)
        tone(12, 456, 345)
        tone(12, 890, 234)
        tone(12, 890, 213)
        tone(12, 890, 768)
        tone(12, 890, 123)
        tone(12, 120, 788)
        tone(12, 120, 111)
        tone(12, 234, 123)
def sound5():
    while True:
        tone(12, 678, 100)
        tone(12, 456, 200)
        tone(12, 324, 100)
        tone(12, 321, 200)
        tone(12, 987, 100)
        tone(12, 545, 200)
        tone(12, 321, 100)
        tone(12, 741, 200)
        tone(12, 123, 100)
        tone(12, 776, 200)
        tone(12, 876, 100)
        tone(12, 234, 200)
        tone(12, 543, 100)
        tone(12, 456, 200)
def sound6():
    while True:
        tone(12, 342, 123)
        tone(12, 12, 200)
        tone(12, 345, 300)
def sound7():
    while True:
        tone(12, 234, 50)
        tone(12, 567, 60)
        tone(12, 890, 100)
def sound8():
    while True:
        tone(12, 100, 100)
        tone(12, 200, 100)
        tone(12, 500, 200)
def sound9():
    while True:
        tone(12, 100, 100)
        tone(12, 600, 50)
        tone(12, 200, 50)
def sound10():
    while True:
        tone(12, 500, 200)
        tone(12, 100, 400)
        tone(12, 300, 120)
def sound11():
    while True:
        tone(12, 382, 158)
        tone(12, 102, 307)
        tone(12, 345, 577)
def sound12():
    while True:
        tone(12, 123, 100)
        tone(12, 243, 200)
        tone(12, 456, 300)
def sound13():
    while True:
        tone(12, 874, 400)
        tone(12, 725, 500)
        tone(12, 684, 100)
def sound14():
    while True:
        tone(12, 345, 200)
        tone(12, 154, 300)
        tone(12, 363, 400)
def sound15():
    while True:
        tone(12, 434, 500)
        tone(12, 345, 100)
        tone(12, 789, 200)
def sound16():
    while True:
        tone(12, 879, 300)
        tone(12, 123, 400)
        tone(12, 234, 500)
n = 0
if n == 0:
    pass
elif n == 1:
    sound1()
elif n == 2:
    sound2()
elif n == 3:
    sound3()
elif n == 4:
    sound4()
elif n == 5:
    sound5()
elif n == 6:
    sound6()
elif n == 7:
    sound7()
elif n == 8:
    sound8()
elif n == 9: 
    sound9() 
elif n == 10:
    sound10()
elif n == 11:
    sound11()
elif n == 12:
    sound12()
elif n == 13:
    sound13()
elif n == 14:
    sound14()
elif n == 15:
    sound15()
elif n == 16:
    sound16() 

if start.value():
    n==1
if nextt.value():
    n +=1
if back.value():
    n -=1